Spring-AMQP RPC container - spring-amqp

Exist a container on the spring-amqp that support a reply-to feature?
I want make RPCs like https://www.rabbitmq.com/tutorials/tutorial-six-java.html, but using spring-amqp.

Yes. Documentation here.
On the server side, the message listener container, when used with a message listener adapter will automatically handle the replies. You can also use the template's ...receiveAndReply methods on the server side.
EDIT
Note that we now have Spring Boot implementations of all 6 tutorials.

Related

RabbitMQ - shovel plugin, accessing headers (properties) form Azure Service Bus

I need to implement rabbitMQ as sort of a middleware between Azure service bus and my rails app.
The message that is being sent uses headers which i also need to capture.
So, is there a way for shovel-plugin to also include headers with the shoveled payload?
Whenever i get the message from the shovel all the original headers are gone.
Also I am using Bunny as an amqp client in the app
Thanks!
EDIT:
Found this PR thanks to RabbitMQ slack:
https://github.com/rabbitmq/rabbitmq-server/issues/2745
It seems that they are aware of the issue
I just created a Python middleware that handles appending headers to the payload and passes the data to RabbitMQ queue later on since it's literally 30 lines of code

Start and verify Dart VM service

I have a two part question.
First, what Dart command should I use to "start"
the VM service listening for requests, with possibly
giving it what host and port number to use.
I'm using Windows, and I don't need the Observatory possibly
interfering.
I'm currently trying to use this, after I CD into the project's directory:
dart --pause_isolates_on_start bicycle
And the second part of the question is, is it possible to verify
that the VM service is there and listening on whatever port?
I want to be able to send a request to the VM service,
from a WebSocket client, and get back a response.
After I give the above command, if I do a 'netstat'
it doesn't look like there is anything there listening.
And any attempts at trying to connect to the VM service get
a connection refused Exception, same as if I didn't even
try to start the VM service.
UPDATE:
I was looking at the intelliJ plugin code, to see how they did their connect,
and saw that they used "ws://localhost:8181/ws", I was trying to use
"ws://localhost:8181", and now it's finally getting past the handshake,
the server was returning "200 OK" instead of "101" before.
I'm assuming that I'm talking to the Observer at this point,
and not the VM service, I'm not sure, but at least I'm further along..
When it worked, I was using:
dart --enable-vm-service --pause_isolates_on_start bicycle.dart
Thanks!!
dart --help -v prints
--observe[=<port>[/<bind-address>]]
The observe flag is a convenience flag used to run a program with a
set of options which are often useful for debugging under Observatory.
These options are currently:
--enable-vm-service[=<port>[/<bind-address>]]
--pause-isolates-on-exit
--pause-isolates-on-unhandled-exceptions
--warn-on-pause-with-no-debugger
This set is subject to change.
Please see these options for further documentation.
It depends on what exactly you want to do, but as far as I know the Observatory just uses this service and if you don't access any of its features, it won't add additional load to the process.
There is a Dart client API https://pub.dartlang.org/packages/vm_service_client and a documentation about the protocol https://github.com/dart-lang/sdk/blob/master/runtime/vm/service/service.md
Perhaps this is what you are looking for
enum EventKind {
// Notification that VM identifying information has changed. Currently used
// to notify of changes to the VM debugging name via setVMName.
VMUpdate,
// Notification that a new isolate has started.
IsolateStart,
used with Events https://github.com/dart-lang/sdk/blob/master/runtime/vm/service/service.md#events

Communicating with ActionCable from different host

I have an api server on one host (say, host1) and a rails5 application on another (host2). Host1 app is written in python, if it matters.
Host1 processes incoming events and should send the result in a json object to the rails application. Rails should receive this object and process further.
What is the correct syntax/protocol/way of sending data from host1 to action_cable on host2 so that the data is streamed_from that channel? I'm okay with setting up cables etc, but I cannot figure out how and where should host1 send its messages.
I have almost decided to POST json to rails but this does not seem to be the true way as the data is updated frequently and a websocket seems to be the best solution.
So, as expected, that was pretty easy and straightforward once you know the answer.
This article is the main source of my inspiration and it makes everything much clearer than the action_cable guides.
In short, I had to ensure that the connection is identified_by and that there's a method responsible for the data processing.
The main caveat was although in stringifying the messages sent to host1. You just have to be careful here and double check all the quotes/slashes.

Adding custom headers using AmqpProxyFactoryBean + AmqpInvokerServiceExporter

I have two separate services communicating using AmqpProxyFactoryBean (the "client") and AmqpInvokerServiceExporter (the "server"). Now, I'd like to include some custom headers on every request made through the AMQP proxy and be able to access them on the "server". Is there any easy way I can achieve this?
Since AmqpClientInterceptor uses AmqpTemplate to send and receive AMQP messages, you can provide for that RabbitTemplate any custom MessageConverter. And populate any additional headers from your toMessage() implementation.
However I'm not sure that you will be able to access to those custom header on the server side. We end up there just with RemoteInvocation.invoke().
So, seems for me you finally come up to the solution with an additional RPC param.
From other side that custom header may be useful for other AQMP routing scenarios when you can route that RPC message not only to the RPC queue.
Consider using Spring Integration AMQP Gateways instead of remoting over rabbitmq; that way you have complete control over the headers passed back and forth.
If you don't want to use Spring Integration, you can use the RabbitTemplate sendAndReceive methods on the client and either the receiveAndSend or a listener container on the server.
Again, this gives you full control over the headers.

ServiceMix + broadcasting message

New to ServiceMix, I'm not sure if it can do what I need:
I've an interface defined by wsdl
I have several endpoints that implement that interface defined by the wsdl
I've a service that can only send the message to one endpoint.
Can service mix do the following:
Producer sends to an endpoint in servicemix (with the wsdl).
ServiceMix broadcasts to the different endpoints the message.
Thanks for the advice and / or pointers!
The simplest would be to use a Camel Recipient List. This would allow you to have either static or dynamic destinations for your broadcast.
It sounds as if your application doesn't require termination of the SOAP message (de/serialize the payload to/from an object) at the ServiceMix consumer. Therefore it can be kept very simple by using a Camel Jetty proxy:
There are further details on the link above on how to configure static (the example above) and dynamic routing.
If your application changes and does require termination of the SOAP message at the ServiceMix consumer in the future, then change out the Camel Jetty consumer endpoint with a Camel CXF endpoint and set bridgeEndpoint to false.
As for ServiceMix you will need to enable the Camel Jetty component. To have it enabled by default you need to edit the etc/org.apache.karaf.features.cfg file and add camel-jetty to the featuresBoot property. This is typically the best practice for features required by your application. You can also install the feature at the ServiceMix console with the command "features:install camel-jetty".
The Recipient List capability is part of the Camel Core API which is installed by default and if not, as a dependency of any other Camel component.
Best Regards,
Scott ES

Resources