How to view Message list in HornetQ - jboss

We have limited the number of maxSession to 5
#ActivationConfigProperty(propertyName = "maxSession", propertyValue = "5")
If more than 5 concurrent request comes, then it has to wait in the queue. Is there any option to view the number of waiting messages in the queue as a list and manage the queue. Is there any API to view and manage the queue. For example, if a JMS message is waiting for long time, using queue management we can re-initiate message or we can drop the message.

JMS Browsers are made to do that.
You can also use the Management API to do that.
Also, the issue with you doing that is going to be concurrency.
The message may be gone by the time you use anything to list the message.
Also, have you looked at expired messages? if you want a timeout for the message, you could set expiration and listen to the expiry queue. That would be a better design for your application.

Related

Sync data from REST and Websockets

we are building chat application similar to messenger. There is required behavior:
User log in
User should see last N messages, and he should be able to load older messages
New messages should be appended as well
My solution:
I would like to use websockets for this purpose with combination of REST. My idea was that client application decide by message id which messages need. So REST will be used for initial fetching of messages and fetching older messages.
New messages will received by websockets
Possible issue which I should handle:
Application starts subscribing websocket channel for new messages and send request for old messages without initial message id
There is chance that after calling GET request new message come, and will be stored in DB
Client application started subscribing websocket channel so message will received by websockets.
GET request didn't know about this message and fetch last N messages where this new messages will occured and client application will have duplicate record and have to filtered this messages
Can you give me advice if there is some elegant way how to handle this case? Thank you.
I would resolve your task having in mind the following:
The client application should know only about the topic to which to listen. And not the ID of the message starting from which to listen.
It is up to the server to decide what to return (even time should always be tracked server-side).
The WebSocket is used as a transport for STOMP (simply to not reinvent the wheel). The WebSocket connection could be opened once the client application is loaded and not when it is entering the "listen for messages" state. But topic subscription should be performed when necessary.
You can always send GET request and initiate a STOMP subscription simultaneously (almost simultaneously, well with a delay of 1-2 nano-second). And those always should be processed in different promises. But I would align those in the following way: first, the STOMP subscription is initiated, And a specific message on subscription with the initial timestamp of the start of subscription is delivered; second, REST request to get previous 10-100 messages for the TOPIC prior to a specific timestamp (received from STOMP) is performed.
Getting the last 10 messages (which are prior to subscription moment) could be delivered as by REST as by STOMP approach: you can always react to a subscription event on your server-side, and deliver client-specific messages.
Regarding the problem of multiple identical messages from different "data channels", it is easily resolvable: your client (hope that is not jquery, but rather Angular or React or Vue or anything else) will be storing all the data in a single collection in a controller, and filtering and checking by message-id that only unique entries are stored is easy.
BUT if your system will produce hundreds of thousands of messages per second: I guess HTTP-based protocols are not your choice in this case.

How to get new message detailes via Gmail push notifications?

I have java server application. And I need to monitor a lot of gmail accounts to be able to send push notifications to mobile devices about new Inbox messages.
I need to know sender email and message subject to send push notification.
And I tried Gmail push notifications system (webhooks option)
If I understood everything correctly in order to get needed info for each new message for each user there is a following scenario:
Google sends me email and history id via https request.
I call history API and get new message ids for user
I request message info by message id
That means that I need 2 additional requests for each new message of each user. And it looks quite hard if server needs to handle several new messages each second. And I still don't see other way.
Is there any way to make it shorter? (e.g. to make google send me not only history id but needed new message details or at least make one additional request, but not two)
Thanks!
We tried using Push notifications but the volume of requests generated has meant that we poll on a timed basis instead. It is worth noting that you will get Push notifications for any change to the message such as a label change, a read status change etc. As you say there are many requests.
If you need the notifications real-time I don't see how you can avoid the process that you outline.
If you don't need it real-time then you can poll or at the least check for Push notifications per account on a timed basis and if some have been received retrieve any new messages in a batch rather than a single request.
I was facing the same problem. History API was not giving recent messageId. I solved this problem by hitting THREAD API where i set Q = last 5 min timestamp.
Webhook push notification is helping to notify a new mail has come. After i get all messages last 10 min with THREAD API.

Logging who purged a queue in MSMQ

I'm looking for a way to know who/what purged a queue (specifically Errors queue) in MSMQ. I know that messages were purged because they end up in "Transactional dead-letter messages" with the Type set to "Acknowledgement QueuePurged". But is there any way to know which AD user (or process?) triggered this? Nothing seems to be logged in Event Viewer.
There will be nothing in the security event viewer as there is no auditing enabled by default.
Auditing Message Queuing Objects

RabbitMQ Structure For Private Messaging

I am currently looking to buildout a messaging service where users can send and receive messages privately between each other. I may have a need for multi-user chat, but for the most part, I only want single recipients to be able to read messages sent to them.
With looking at RabbitMQ, does it make sense to use one exchange, and create a queue for each user when they login and destroy each queue on logout? Are there major performance issues with creating a queue for each user or are there better alternatives?
I am building a REST API and plan on having users send messages to others through an endpoint (/send) and subscribe to their own message streams via websockets or something similar. I will probably store messages in MongoDB as well, so users can access all of their previous messages. Any suggestions on structure are appreciated.
I think your approach is correct. You event don't need an exchange if you will use the default exchange (AMQP Default). And during login create a new queue and keep queue name same as user name. (Just need to make sure user names are unique) And if you publish message to the default exchange with username (ie: queue name) as routing key, RbbitMQ will route that message to that queue only. And on logout if you delete the queue then user is going to miss the messages when he is not online. If it is OK then create queue after login and use the configuration exclusive which says queue gets deleted when there is no consumer. But if you want to keep offline messages then you need to create queue permanently during user signup.

Getting the Id property of an MSMQ mesage with NServiceBus

I need to get the Id of a msmq message inside of my handler so I can write that Id to a log.
When a message is sent to the error queue an email is sent informing us of a failed message. Once the error that caused the message is resolved we need to use the 'ReturnToSourceQueue' NServiceBus tool to try that message again. Without logging that Id, it would be difficult to track down which message is which when looking through the message queues.
Every where I've looked suggests that Bus.CurrentMessageContext.Id will give me the same Id that's in the Message ID column when looking at the queues in ComputerManagement->Services and Applications->Message Queuing->[Some Queue]->Queue messages. However, those ids don't seem to be the same.
What am I missing?
The reason that the message ID that you see in MMC plugin or Queue Explorer is different is that when the message is "moved" to the error queue, what actually happens is that a new MSMQ message is created with the same body and headers and that is sent to the error queue.
Also, when the processing a message fails, NServiceBus already logs this for you and includes the ID of the message, so that's already done for you.
If you take the ID that was logged and pass that to the ReturnToSourceQueue tool, everything will just work.
The last piece of the puzzle for you is sending an email when a message fails. Now, I'm not sure that that is the wisest idea as you may end up spamming your ops team when a database goes offline or a 3rd party webservice becomes unresponsive. Still, if that's what you want to do, then I'd suggest using an email appender for when errors are logged.
Finally, let me say that we're in the process of building this kind of notification functionality into the Particular Service Platform around NServiceBus. We've got a UI showing errors and allowing messages to be reprocessed coming as a beta in November '13 and the notification functionality will probably be ready towards the end of the year.
It's really a question of whether you want to wait or to build this yourself.
Just create an instance of your bus in your handler:
public IBus Bus { get; set; }
Then use that to get the message id:
this.Bus.CurrentMessageContext.Id
The Bus instance will be injected when the handler is called.
EDIT
Now that I have actually read the question...
The CurrentMessageContext.Id returns what's in the message header under the CorrId field. This can be seen in the Label column in Server Management.
The Message ID displayed in the MessagId column is the message ID as it existed on the sending computer. I am not sure how to access this value from CurrentMessageContext but you should not need to do this to find a local message.