Moving Mail Messaged with Spring Integration - spring-integration

I 'm doing mail processing with spring-integration. I got the receiving part working, but I would like to move the messages to different folders after processing.
Unfortunately, the MimeMessages received from the Adapter are not 'real' javax.mail.Message, but an IntegrationMimeMessage (in AbstractMailReceiver)
Is there a way to access the 'javax.mail.Message' so that I can move them with plain JavaMail? Or does spring-integration provide an adapter that can move messages ? Could not find any in the documentation.

Related

If I have multiple clients subscribed to a pusher channel, can I have only one of them receive the message?

I have a load balanced situation, in which I have multiple instances running. I'm subscribing to a channel in each instance, but I only want one of them to trigger when a message comes through.
Is there any way to accomplish this?
If you want to have different subscribers and some are only interested in a subset of the messages distributed by a your publisher. Then your messaging service must allow subscribers to specify the topics relevant for them and/or inspect the messages and specify the content they are interested in.
that kind of goes against pub/sub pattern. Even if you added a streaming application in between you channel and your clients, this will still need to read all messages to decide which one to filter out to different clients
If you mean, for example, Android or IOS notifications, then you are able to store push tokens in your database, filter them and send a message only selected users.
P.S. It could help if you provide more details about the environment of push notifications you ask, and an architecture of the application you develop.

Difference between Spring Inbound channel adapters and application event listing message producers

I am working on a POC using Spring Integration and STOMP. The initial POC is successful.
I followed the adapters configuration mentioned in https://docs.spring.io/spring-integration/reference/html/stomp.html#stomp
In my POC, I did not include the last two #Bean definitions from the above link.
Inbound Channel Adapter and Message Handlers were sufficient to handle the incoming messages.
Now, my question is:
What is the difference between Inbound channel adapters and application event listing message producers?
Is ApplicationListener used when we follow DSL as mentioned in an example here?
Thanks,
Mahesh
Well, as you noticed in that Spring Integration documentation about STOMP support there is some bunch of ApplicationEvents emitted by STOMP Channel Adapters. You indeed can handle them using regular ApplicationListener (#EventListener) if your logic for handling those events is pretty much simple and doesn't need further distribution. But if your logic is much complicated and you may need store an even (or its part) in some database, or send via email, do that in parallel after some aggregtion, etc., then indeed that ApplicationEventListeningMessageProducer is much better solution when we have Spring Integration on board already.
However if you talk about a StompInboundChannelAdapter nature and relationship with those mentioned events, you need to take a look into the StompIntegrationEvent implementations. You quickly realize that there is no events for payload in the STOMP frame. So, that is what is done really by the StompInboundChannelAdapter - it produces messages based on the body from STOMP frame.
All the mentioned events emitted fro that channel adapter are more about that adapter state sharing for possible management in your application.

How to send ActiveMQ VirtualTopic in node js?

How to send ActiveMQ VirtualTopic in node js ?
Am using stompit library for send and receive queue.
This will working properly.
I need to send virtual topic, How to implement in node ?
ActiveMQ.Advisory.Producer.Topic.VirtualTopic
ActiveMQConnectionFactory allow to create producer and topic in java
But, there is no option like that in node js.
https://i.stack.imgur.com/o5tqE.png
If I produce from Java then
Topic: Lenovo.* (marked red color in screen shot)
then automatically created ActiveMQ.Advisory.Producer.Topic.Lenovo.*
(Marked green color in screen shot)
Not create ActiveMQ.Advisory.Producer.Topic when produce from node
Virtual destinations are just named endpoints like any other. To send to one the client would send to a destination like '/topic/VirtualTopic.Orders' and then consume from the queue '/queue/Consumer.A.VirtualTopic.Orders' and that is about it. See the documentation for the Virtual Destinations feature in ActiveMQ to understand how the naming works.

Send my message only to subscribed server and not to my other servers

How do I send my message that is published to a Redis channel only to subscribed server (which is connected to the subscriber) and not to my other servers (where the required subscriber isn't connected).
I'm using Socket.IO and Redis server.
Have you read the documentation?
not programmed to send their messages to specific receivers (subscribers). Rather, published messages are characterized into channels, without knowledge of what (if any) subscribers there may be
I other words, you cannot target a specific subscriber.
Depending on what you are trying to achieve, you can consider using multiple channels, with each consumer using its own.

Spring integration: Best way to implement retry for remote HTTP calls

I have channel with queue and it has several messages.
All of them should go to the remote system via http-outbound-gateway
If remote system is not available where do my message go? To the nowhere?
How can I retry later? Does there is something like "error-channel" for http-outbound-gateway?
PS:
I found way I probably like: using transactional chain + PseudoTransactionManager. It works.
But could I do it with less XML?
See this biog post and the associated sample for using the MessageHandlerRetryAdvice...
http://spring.io/blog/2012/10/09/what-s-new-in-spring-integration-2-2-part-4-retry-and-more
After the retries as exhausted you can send the message to a <delayer/> and then send it through again.

Resources