1
votes

I have seen a number of examples where an ActiveMQ TCP transport in Camel is exposed using XML but none using Java.

Anyone know how to do this?

I can't seem to find an example anywhere.

I am using Spring Boot with Camel, ActiveMQ.

2

2 Answers

0
votes

Yes you can send Java objects over JMS. The only thing you need to make sure, is that your Java object is serializable. That is, the class should implement Serializable. After that, simply send and receive the Java object to ActiveMQ i.e.

<to uri="activemq:queueName"/>
0
votes

I believe that I have found the answer.

If creating a new BrokerService...

    //whatever URI, broker name you want
    String uri = "tcp://localhost:61617";
    String brokerName = "my-tcp-broker";

    BrokerService brokerService = new BrokerService();
    brokerService.setBrokerName(brokerName);     

    TransportConnector connector = new TransportConnector();
    connector.setUri(new URI(uri));
    brokerService.addConnector(connector);
    brokerService.start();

Or, if you are using an existing BrokerService...

    BrokerService brokerService = BrokerRegistry.getInstance().lookup(brokerServiceName);
    TransportConnector connector = new TransportConnector();
    connector.setUri(new URI(uri));
    connector.setBrokerService(brokerService);
    brokerService.addConnector(connector);
    connector.start();