Quantcast
Channel: Service Bus forum
Viewing all articles
Browse latest Browse all 1916

Abandon() in azure service bus , method takes message to dead letter queue

$
0
0

Hi All,

  I'm new to azure service bus, I'm developing a sample publish/subscribe application using java sdk. In this exercise what I want to achieve is I will publish 50 messages (json)to a queue, these are in below format.

[{'lastname'='test0','firstName'='success0'}...{'lastname'='test49','firstName'='success49'}]

In receiver application at 25th message , I want this message to abandon, so the 25th message will be

available in queue. But when I run application, all 49 messages are completed and one message went to

dead letter queue. I got below exception.

Either receive link to 'asb.java.pub' closed with a transient error and reopened or the delivery was already settled by complete/abandon/defer/deadletter.
2019-05-09 06:17:19 ERROR MessageAndSessionPump:241 - Completing message with sequence number '5002' failed
java.lang.IllegalArgumentException: Delivery not found on the receive link.
at com.geico.messaging.servicebus.primitives.CoreMessageReceiver.generateDeliveryNotFoundException(CoreMessageReceiver.java:1319)
at com.geico.messaging.servicebus.primitives.CoreMessageReceiver.updateMessageStateAsync(CoreMessageReceiver.java:1161)
at com.geico.messaging.servicebus.primitives.CoreMessageReceiver.completeMessageAsync(CoreMessageReceiver.java:1046)
at com.geico.messaging.servicebus.MessageReceiver.lambda$3(MessageReceiver.java:267)
at java.util.concurrent.CompletableFuture.uniComposeStage(Unknown Source)
at java.util.concurrent.CompletableFuture.thenCompose(Unknown Source)
at com.geico.messaging.servicebus.MessageReceiver.completeAsync(MessageReceiver.java:262)
at com.geico.messaging.servicebus.MessageReceiver.completeAsync(MessageReceiver.java:255)
at com.geico.messaging.servicebus.MessageAndSessionPump.lambda$6(MessageAndSessionPump.java:220)
at java.util.concurrent.CompletableFuture.uniHandle(Unknown Source)
at java.util.concurrent.CompletableFuture$UniHandle.tryFire(Unknown Source)
at java.util.concurrent.CompletableFuture$Completion.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

.here is my publishing code

ConnectionStringBuilder connectionResolver = new ConnectionStringBuilder(connectionString, "asb.java.pub"); 

QueueClient sendClient = new QueueClient(connectionResolver,ReceiveMode.PEEKLOCK);

for(int i =0;i<50;i++){Message message = new Message("{'lastname' = 'test"+i+"', 'firstName' ='success"+i+"'}");

message.setLabel("name");sendClient.send(message);}sendClient.close();

here is my subscriber code
IMessageHandler ih=new IMessageHandler() {				
public CompletableFuture<Void> onMessageAsync(IMessage message)   {
byte[] body = message.getBody();					
Map map = GSON.fromJson(new String(body, UTF_8), Map.class);	
try{						if(map.get("lastname").equals("test25")){						return receiveClient.abandonAsync(message.getLockToken());
;
}catch(Exception e){						e.printStackTrace();						
}
CompletableFuture.completedFuture(null);
}
public void notifyException(Throwable throwable, ExceptionPhase exceptionPhase) {
					System.out.printf(exceptionPhase + "-" + throwable.getMessage());
}
};

			receiveClient.registerMessageHandler(ih, executorService);

my question is why message goes to deadletter , when I call abandon method. Can't I made a specific message to abandon or autocomplete false.So that that message will be available in the queue .

Thank you.



Viewing all articles
Browse latest Browse all 1916

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>