get only first message
Hi,
I want to receive only the first message with property in a Queue.
How to get this? Will this utility will help ?
./sdkperf_jms.sh
Or any other choice ?
Saw this article..Any hint - on how to re-write to receive only first message?
https://tutorials.solace.dev/jcsmp/topic-to-queue-mapping/
These messages are now on your queue. You can validate this through SolAdmin by inspecting the queue. Now receive the messages using a flow consumer as outlined in detail in previous tutorials.
ConsumerFlowProperties flow_prop = new ConsumerFlowProperties(); flow_prop.setEndpoint(queue); Consumer cons = session.createFlow(new SimplePrintingMessageListener(), flow_prop); cons.start(); try { latch.await(); // block here until message received, and latch will flip } catch (InterruptedException e) { System.out.println("I was awoken while waiting"); }
Answers
-
Hi @sachiek . So you only want to receive a single message off a queue? And then what? Disconnect? May I ask what the use case is?
SdkPerf tools will generally try to receive as many messages off a queue as fast as possible, so probably not the best tool there.
If you want to write some code, and very tightly control the number of messages you receive, you could use a blocking Flow Session, where you pass
null
into thecreateFlow()
method.OR perhaps I've misread you, and you want to choose the first message off a queue that has a certain property..??
1 -
@Aaron said:
Hi @sachiek . So you only want to receive a single message off a queue? And then what? Disconnect? May I ask what the use case is?SdkPerf tools will generally try to receive as many messages off a queue as fast as possible, so probably not the best tool there.
If you want to write some code, and very tightly control the number of messages you receive, you could use a blocking Flow Session, where you pass
null
into thecreateFlow()
method.OR perhaps I've misread you, and you want to choose the first message off a queue that has a certain property..??
I also trying SEMP API - will update by tomorrow. Right now only able to pull messages i.e first 10. But not able to validate if there is first message in that messages pulled. Will further drill down by tomorrow.
0 -
"curl -X GET -u $user:$password $urlip:80/SEMP/v2/monitor/msgVpns/$vpn/queues/$queueName/msgs -H \"content-type: application/json\""
Is there any option to limit this to get only first message in this SEMP API ? This one by default able to only give 10 messages.0 -
SEMP is not a messaging API, it's an admin API and has no access to the message bodies.
@Aaron asked about your use case for only wanting 1 message. One of the use cases the broker supports is a queue acting as a Last Value Queue (LVQ) where the queue depth is 0 and therefore there is always only the last message published to the queue. So if that suits your use case, you could implement a LVQ and any consumer would only get a single message.
https://docs.solace.com/PubSub-Basics/Endpoints.htm#LVQs0 -
@amackenzie @Aaron - Had used custom Java class to achieve this. Thank you.
0 -
@sachiek said:
@amackenzie @Aaron - Had used custom Java class to achieve this. Thank you.Yes, only first message.
0