Monday 15 April 2013

java - Apache camel,RabbitMQ how to send messages/objects -



java - Apache camel,RabbitMQ how to send messages/objects -

i hope can provide help on matter.

i using camel rabbitmq , testing purpose trying send message queue, i'm trying display in rabbitmq interface , read back.

however can't working.

what believe works created, in exchange tab of rabbitmq management interface, new exchange. in java code send message exchange. when code executed, can see spike in web interface showing has been received can't see has been received. when seek read, can't read , next errror: < in route: route(route2)[[from[rabbitmq://192.168.59.103:5672/rt... because of route route2 has no output processors. need add together outputs route such to("log:foo").

can provide me practical illustration on how send message,see in web interace , read it? tutorial showing process appreciated.

thank you

================= sec part

the error i'm getting following:

caused by: com.rabbitmq.client.shutdownsignalexception: channel error; reason: {#method<channel.close>(reply-code=406, reply-text=precondition_failed - cannot redeclare exchange 'rhsearchexchange' in vhost '/' different type, durable, internal or autodelete value, class-id=40, method-id=10), null, ""} @ com.rabbitmq.utility.valueorexception.getvalue(valueorexception.java:67) @ com.rabbitmq.utility.blockingvalueorexception.uninterruptiblegetvalue(blockingvalueorexception.java:33) @ com.rabbitmq.client.impl.amqchannel$blockingrpccontinuation.getreply(amqchannel.java:343) @ com.rabbitmq.client.impl.amqchannel.privaterpc(amqchannel.java:216) @ com.rabbitmq.client.impl.amqchannel.exnwrappingrpc(amqchannel.java:118) ... 47 more

i have next settings:

i error, believe i’m doing wrong uri , have define parameters i’m missing exchange of direct type queue of durable type , uri : rabbitmq://192.168.59.105:5672/rhsearchexchange?username=guest&password=guest&routingkey=rhsearchqueue

any input on this?

thanks

so able figure out yesterday, had same (or @ to the lowest degree similar) problems having.

the options have in rabbitmq uri must match options exchange created with. example, in configuration, had exchange called tasks direct type, durable, , not configured autodelete. note default value autodelete alternative in rabbitmq camel component true. additionally, wanted messages routing key camel. means rabbitmq uri needed like:

rabbitmq:localhost:5672/tasks?username=guest&password=guest&autodelete=false&routingkey=camel

additionally, wanted read existing queue, called task_queue rather have rabbitmq camel component declare it's own queue. therefore, needed add together additional query parameter, rabbitmq uri

rabbitmq:localhost:5672/tasks?username=guest&password=guest&autodelete=false&routingkey=camel&queue=task_queue

this configuration worked me. below, added java code snippets code configures exchange , queue , sends message, , camel route configuration.

exchange , queue configuration: rabbitconnfactory = new connectionfactory(); rabbitconnfactory.sethost("localhost"); final connection conn = rabbitconnfactory.newconnection(); final channel channel = conn.createchannel(); // declare direct, durable, non autodelete exchange named 'tasks' channel.exchangedeclare("tasks", "direct", true); // declare durable, non exclusive, non autodelete queue named 'task_queue' channel.queuedeclare("task_queue", true, false, false, null); // bind 'task_queue' 'tasks' exchange routing key 'camel' channel.queuebind("task_queue", "tasks", "camel"); sending message: channel.basicpublish("tasks", "camel", messageproperties.persistent_text_plain, "hello, world!".getbytes()); camel route: @override public void configure() throws exception { from("rabbitmq:localhost:5672/tasks?username=guest&password=guest&autodelete=false&routingkey=camel&queue=task_queue") .to("mock:result"); }

i hope helps!

java spring apache-camel rabbitmq

No comments:

Post a Comment