Problems passing Camel VM messages between multiple Spring Boot applications in Tomcat

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Problems passing Camel VM messages between multiple Spring Boot applications in Tomcat

Steve973
We have an application stack, deployed in Tomcat, that consists of several
Spring Boot applications. As part of our operations, we want to send some
messages to a vm endpoint, where a camel route will consume those messages
and then publish them to a JMS topic for any of the other Spring Boot
applications that are interested in messages on that topic.

When I start the application stack, there are three spring boot apps that
utilize camel, and I see camel start properly in the logs. But when one of
the apps sends a message to the vm endpoint, the route that consumes from
that endpoint and routes the messages to the jms topic does not seem to get
that message. I have placed the camel-core jar in my tomcat lib directory.
In the spring boot maven plugin configuration, I have specified an
exclusion of the camel-core jar. Oddly enough, that jar is in the
WEB-INF/lib of the war anyway! So I have stopped Tomcat, removed that jar
from the exploded war, and restarted Tomcat, but that does not change the
behavior of the messaging.

Here are the versions that we are using:

   - Spring Boot 2.3.1
   - Camel 3.4.2
   - Tomcat 8.5.5

The first spring boot app that links everything together, with the camel
route that consumes from the vm endpoint and produces that message on the
jms topic is our "routing engine". It uses camel-spring-boot-starter,
spring-boot-starter-artemis, camel-vm-starter, artemis-jms-server and
camel-jms-starter. Its RouteBuilder's configure method looks like this:

from("vm:task")
    .log(LoggingLevel.WARN, "********** Received task message");
    .to("jms:topic:local.private.task")
    .routeId("taskToJms");

The app that produces messages to the vm endpoint uses
camel-spring-boot-starter and camel-vm-starter. In that app, it has a
@Service class that receives a ProducerTemplate that is auto-wired in the
constructor. When the application invokes this component to send the
message, I see a line in the logs that says

o.a.c.impl.engine.DefaultProducerCache (169) - >>>> vm://task Exchange[]

so it appears that the message is being produced and sent properly to the
vm endpoint. However, I see no indication that it has been
received/consumed in the routing engine's camel route, since the route's
log line is not logging anything, and since I see no other indications of
receiving the message in the log. The strange thing is that I am not
getting the error of not having any consumers on the vm:task endpoint that
I was getting before I put the camel-core jar in tomcat's lib directory.

Am I doing anything obviously wrong? How can I get the spring boot maven
plugin to really exclude camel-core? And why are the messages (sent to the
vm endpoint) not being consumed by the route in the routing engine? Thanks
in advance for any help.
Reply | Threaded
Open this post in threaded view
|

Re: Problems passing Camel VM messages between multiple Spring Boot applications in Tomcat

Claus Ibsen-2
Hi

You would need more JARs than just camel-core, such as camel-vm etc as
well, and many others.
And this is really IMHO a bad practice on tomcat to mess with
classloading using this shared lib.






On Thu, Aug 6, 2020 at 4:46 PM Steve973 <[hidden email]> wrote:

>
> We have an application stack, deployed in Tomcat, that consists of several
> Spring Boot applications. As part of our operations, we want to send some
> messages to a vm endpoint, where a camel route will consume those messages
> and then publish them to a JMS topic for any of the other Spring Boot
> applications that are interested in messages on that topic.
>
> When I start the application stack, there are three spring boot apps that
> utilize camel, and I see camel start properly in the logs. But when one of
> the apps sends a message to the vm endpoint, the route that consumes from
> that endpoint and routes the messages to the jms topic does not seem to get
> that message. I have placed the camel-core jar in my tomcat lib directory.
> In the spring boot maven plugin configuration, I have specified an
> exclusion of the camel-core jar. Oddly enough, that jar is in the
> WEB-INF/lib of the war anyway! So I have stopped Tomcat, removed that jar
> from the exploded war, and restarted Tomcat, but that does not change the
> behavior of the messaging.
>
> Here are the versions that we are using:
>
>    - Spring Boot 2.3.1
>    - Camel 3.4.2
>    - Tomcat 8.5.5
>
> The first spring boot app that links everything together, with the camel
> route that consumes from the vm endpoint and produces that message on the
> jms topic is our "routing engine". It uses camel-spring-boot-starter,
> spring-boot-starter-artemis, camel-vm-starter, artemis-jms-server and
> camel-jms-starter. Its RouteBuilder's configure method looks like this:
>
> from("vm:task")
>     .log(LoggingLevel.WARN, "********** Received task message");
>     .to("jms:topic:local.private.task")
>     .routeId("taskToJms");
>
> The app that produces messages to the vm endpoint uses
> camel-spring-boot-starter and camel-vm-starter. In that app, it has a
> @Service class that receives a ProducerTemplate that is auto-wired in the
> constructor. When the application invokes this component to send the
> message, I see a line in the logs that says
>
> o.a.c.impl.engine.DefaultProducerCache (169) - >>>> vm://task Exchange[]
>
> so it appears that the message is being produced and sent properly to the
> vm endpoint. However, I see no indication that it has been
> received/consumed in the routing engine's camel route, since the route's
> log line is not logging anything, and since I see no other indications of
> receiving the message in the log. The strange thing is that I am not
> getting the error of not having any consumers on the vm:task endpoint that
> I was getting before I put the camel-core jar in tomcat's lib directory.
>
> Am I doing anything obviously wrong? How can I get the spring boot maven
> plugin to really exclude camel-core? And why are the messages (sent to the
> vm endpoint) not being consumed by the route in the routing engine? Thanks
> in advance for any help.



--
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2
Reply | Threaded
Open this post in threaded view
|

Re: Problems passing Camel VM messages between multiple Spring Boot applications in Tomcat

Steve973
Hi, Claus.  Thank you for your reply and for your feedback on my current
implementation.  I am willing to change it to be simpler/easier/more
foolproof.  What transport would you suggest that I use?  I would be fine
with switching to a JMS queue, or some other component.  I still need to
continue to deploy multiple spring boot applications to a single tomcat
instance (at least for now).

Thanks again,
Steve

On Fri, Aug 7, 2020 at 3:22 AM Claus Ibsen <[hidden email]> wrote:

> Hi
>
> You would need more JARs than just camel-core, such as camel-vm etc as
> well, and many others.
> And this is really IMHO a bad practice on tomcat to mess with
> classloading using this shared lib.
>
>
>
>
>
>
> On Thu, Aug 6, 2020 at 4:46 PM Steve973 <[hidden email]> wrote:
> >
> > We have an application stack, deployed in Tomcat, that consists of
> several
> > Spring Boot applications. As part of our operations, we want to send some
> > messages to a vm endpoint, where a camel route will consume those
> messages
> > and then publish them to a JMS topic for any of the other Spring Boot
> > applications that are interested in messages on that topic.
> >
> > When I start the application stack, there are three spring boot apps that
> > utilize camel, and I see camel start properly in the logs. But when one
> of
> > the apps sends a message to the vm endpoint, the route that consumes from
> > that endpoint and routes the messages to the jms topic does not seem to
> get
> > that message. I have placed the camel-core jar in my tomcat lib
> directory.
> > In the spring boot maven plugin configuration, I have specified an
> > exclusion of the camel-core jar. Oddly enough, that jar is in the
> > WEB-INF/lib of the war anyway! So I have stopped Tomcat, removed that jar
> > from the exploded war, and restarted Tomcat, but that does not change the
> > behavior of the messaging.
> >
> > Here are the versions that we are using:
> >
> >    - Spring Boot 2.3.1
> >    - Camel 3.4.2
> >    - Tomcat 8.5.5
> >
> > The first spring boot app that links everything together, with the camel
> > route that consumes from the vm endpoint and produces that message on the
> > jms topic is our "routing engine". It uses camel-spring-boot-starter,
> > spring-boot-starter-artemis, camel-vm-starter, artemis-jms-server and
> > camel-jms-starter. Its RouteBuilder's configure method looks like this:
> >
> > from("vm:task")
> >     .log(LoggingLevel.WARN, "********** Received task message");
> >     .to("jms:topic:local.private.task")
> >     .routeId("taskToJms");
> >
> > The app that produces messages to the vm endpoint uses
> > camel-spring-boot-starter and camel-vm-starter. In that app, it has a
> > @Service class that receives a ProducerTemplate that is auto-wired in the
> > constructor. When the application invokes this component to send the
> > message, I see a line in the logs that says
> >
> > o.a.c.impl.engine.DefaultProducerCache (169) - >>>> vm://task Exchange[]
> >
> > so it appears that the message is being produced and sent properly to the
> > vm endpoint. However, I see no indication that it has been
> > received/consumed in the routing engine's camel route, since the route's
> > log line is not logging anything, and since I see no other indications of
> > receiving the message in the log. The strange thing is that I am not
> > getting the error of not having any consumers on the vm:task endpoint
> that
> > I was getting before I put the camel-core jar in tomcat's lib directory.
> >
> > Am I doing anything obviously wrong? How can I get the spring boot maven
> > plugin to really exclude camel-core? And why are the messages (sent to
> the
> > vm endpoint) not being consumed by the route in the routing engine?
> Thanks
> > in advance for any help.
>
>
>
> --
> Claus Ibsen
> -----------------
> http://davsclaus.com @davsclaus
> Camel in Action 2: https://www.manning.com/ibsen2
>
Reply | Threaded
Open this post in threaded view
|

Re: Problems passing Camel VM messages between multiple Spring Boot applications in Tomcat

Steve973
In reply to this post by Claus Ibsen-2
Just to give some feedback and closure from my question a whole ago, I
ended up just using a JMS queue to message between the different contexts.
It worked fine, so thank you for letting me know that I should do things
another way.  Since the latest documentation describes how to use the VM
component to message between different contexts in the same JVM, someone
might want to update the documents to warn against this practice in certain
situations, if this truly is a bad practice.  Or maybe list the specific
situations where this is a decent solution, and advise that it should be
avoided in other situations.  Just my two cents, but maybe nobody else
would try it the way I did.

On Fri, Aug 7, 2020, 3:22 AM Claus Ibsen <[hidden email]> wrote:

> Hi
>
> You would need more JARs than just camel-core, such as camel-vm etc as
> well, and many others.
> And this is really IMHO a bad practice on tomcat to mess with
> classloading using this shared lib.
>
>
>
>
>
>
> On Thu, Aug 6, 2020 at 4:46 PM Steve973 <[hidden email]> wrote:
> >
> > We have an application stack, deployed in Tomcat, that consists of
> several
> > Spring Boot applications. As part of our operations, we want to send some
> > messages to a vm endpoint, where a camel route will consume those
> messages
> > and then publish them to a JMS topic for any of the other Spring Boot
> > applications that are interested in messages on that topic.
> >
> > When I start the application stack, there are three spring boot apps that
> > utilize camel, and I see camel start properly in the logs. But when one
> of
> > the apps sends a message to the vm endpoint, the route that consumes from
> > that endpoint and routes the messages to the jms topic does not seem to
> get
> > that message. I have placed the camel-core jar in my tomcat lib
> directory.
> > In the spring boot maven plugin configuration, I have specified an
> > exclusion of the camel-core jar. Oddly enough, that jar is in the
> > WEB-INF/lib of the war anyway! So I have stopped Tomcat, removed that jar
> > from the exploded war, and restarted Tomcat, but that does not change the
> > behavior of the messaging.
> >
> > Here are the versions that we are using:
> >
> >    - Spring Boot 2.3.1
> >    - Camel 3.4.2
> >    - Tomcat 8.5.5
> >
> > The first spring boot app that links everything together, with the camel
> > route that consumes from the vm endpoint and produces that message on the
> > jms topic is our "routing engine". It uses camel-spring-boot-starter,
> > spring-boot-starter-artemis, camel-vm-starter, artemis-jms-server and
> > camel-jms-starter. Its RouteBuilder's configure method looks like this:
> >
> > from("vm:task")
> >     .log(LoggingLevel.WARN, "********** Received task message");
> >     .to("jms:topic:local.private.task")
> >     .routeId("taskToJms");
> >
> > The app that produces messages to the vm endpoint uses
> > camel-spring-boot-starter and camel-vm-starter. In that app, it has a
> > @Service class that receives a ProducerTemplate that is auto-wired in the
> > constructor. When the application invokes this component to send the
> > message, I see a line in the logs that says
> >
> > o.a.c.impl.engine.DefaultProducerCache (169) - >>>> vm://task Exchange[]
> >
> > so it appears that the message is being produced and sent properly to the
> > vm endpoint. However, I see no indication that it has been
> > received/consumed in the routing engine's camel route, since the route's
> > log line is not logging anything, and since I see no other indications of
> > receiving the message in the log. The strange thing is that I am not
> > getting the error of not having any consumers on the vm:task endpoint
> that
> > I was getting before I put the camel-core jar in tomcat's lib directory.
> >
> > Am I doing anything obviously wrong? How can I get the spring boot maven
> > plugin to really exclude camel-core? And why are the messages (sent to
> the
> > vm endpoint) not being consumed by the route in the routing engine?
> Thanks
> > in advance for any help.
>
>
>
> --
> Claus Ibsen
> -----------------
> http://davsclaus.com @davsclaus
> Camel in Action 2: https://www.manning.com/ibsen2
>