RabbitMQ: ConnectionFactory gives "Connection refused" yet I can write all in one .to()
New Camel user here.
I have a Spring Boot / Camel app and successfully got a route working which polls a REST endpoint, splits the JSON array into custom POJOS, transforms each one into one of our Protobufs, and then writes the protobuf out to our RabbitMQ.
Well, it took me quite a bit of work to debug and get that last step working (writing out to the bus). Basically, I could never establish a connection to the bus using ConnectionFactory and instead, eventually figured out how to do it by putting the entire connection/writing to the bus using *just* the .to() statement in the DSL.
So I'm really, really interested to know what I was doing wrong with ConnectionFactory. Any help would be much appreciated!
Ok, so this is what worked:
(newlines added for clarity)
Actually, I have a quick question here: Is doing the above wasteful in the sense that the connection isn't pooled and it's establishing the connection with every single write?
Ok, and this is what didn't work and kept giving me a "java.net.ConnectException: Connection refused" error:
RabbitMQEndpoint endpoint = new RabbitMQEndpoint();
Connection connectionFactory = new RabbitMQConnectionFactorySupport().createFactoryFor(endpoint);
So what am I missing??
For what it's worth, if the above connection worked, I was going to write the bus with the following .to() statement. Does it look correct? In particular, can I specify anything after the 'rabbitmq:' in place of the 'bogusbus'?
Thank you so much for your help!