Skip to content

Commit

Permalink
HORNETQ-1084 - HornetQ does not remove message from queue when the me…
Browse files Browse the repository at this point in the history
…ssage is rolled back and the DLA has no binding
  • Loading branch information
jbertram committed Nov 8, 2012
1 parent a021909 commit 845e556
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/main/org/hornetq/core/server/impl/QueueImpl.java
Expand Up @@ -2093,6 +2093,7 @@ private void sendToDeadLetterAddress(final MessageReference ref, final SimpleSt
{
QueueImpl.log.warn("Message " + ref + " has exceeded max delivery attempts. No bindings for Dead Letter Address " + deadLetterAddress +
" so dropping it");
acknowledge(ref);
}
else
{
Expand Down
Expand Up @@ -83,6 +83,35 @@ public void testBasicSend() throws Exception
Assert.assertEquals(m.getBodyBuffer().readString(), "heyho!");
}

// HORNETQ- 1084
public void testBasicSendWithDLAButNoBinding() throws Exception
{
SimpleString dla = new SimpleString("DLA");
SimpleString qName = new SimpleString("q1");
AddressSettings addressSettings = new AddressSettings();
addressSettings.setMaxDeliveryAttempts(1);
addressSettings.setDeadLetterAddress(dla);
server.getAddressSettingsRepository().addMatch(qName.toString(), addressSettings);
//SimpleString dlq = new SimpleString("DLQ1");
//clientSession.createQueue(dla, dlq, null, false);
clientSession.createQueue(qName, qName, null, false);
ClientProducer producer = clientSession.createProducer(qName);
producer.send(createTextMessage(clientSession, "heyho!"));
clientSession.start();
ClientConsumer clientConsumer = clientSession.createConsumer(qName);
ClientMessage m = clientConsumer.receive(500);
m.acknowledge();
Assert.assertNotNull(m);
Assert.assertEquals(m.getBodyBuffer().readString(), "heyho!");
// force a cancel
clientSession.rollback();
m = clientConsumer.receiveImmediate();
Assert.assertNull(m);
clientConsumer.close();
Queue q = (Queue)server.getPostOffice().getBinding(qName).getBindable();
Assert.assertEquals(0, q.getDeliveringCount());
}

public void testBasicSend2times() throws Exception
{
SimpleString dla = new SimpleString("DLA");
Expand Down

0 comments on commit 845e556

Please sign in to comment.