The Trumpet-Major is a novel by Thomas Hardy published in 1880.
The heroine, Anne Garland, is pursued by three suitors: John Loveday, the trumpet major in a British regiment, honest and loyal; his brother Bob, a flighty sailor; and Festus Derriman, the cowardly son of the local squire.
The setting is the Napoleonic wars, and it seems Miss Garland has a penchant for men in uniform. Of the two brothers, John fights with Wellington in the Peninsular War, and Bob serves with Nelson at Trafalgar.
Unusually for a Hardy novel, most of the characters live happily ever after; however, the ending is debatably an ominous one.