List of usage examples for org.springframework.amqp.rabbit.listener.adapter MessageListenerAdapter setMandatoryPublish
public void setMandatoryPublish(boolean mandatoryPublish)
From source file:org.resthub.rpc.RPCEndpoint.java
/** * Starts the endpoint on the connection specified. * A listener container is launched on a created queue. The listener will * respond to hessian requests. The endpoint is closed by calling the destroy * method.//from w ww . j ava2 s . co m */ public void run() { logger.debug("Launching endpoint for service : " + serviceAPI.getSimpleName()); admin = new RabbitAdmin(connectionFactory); // Add connectionListener to recreate queue when connection fall connectionFactory.addConnectionListener(new ConnectionListener() { public void onCreate(Connection connection) { createQueue(admin, getRequestQueueName(serviceAPI)); } public void onClose(Connection connection) { } }); // Create the queue normaly the first time this.createQueue(admin, getRequestQueueName(serviceAPI)); MessageListenerAdapter listenerAdapter = new MessageListenerAdapter( new RawMessageDelegate(serviceAPI, serviceImpl, serializationHandler)); listenerAdapter.setMessageConverter(null); listenerAdapter.setMandatoryPublish(false); listenerContainer = new SimpleMessageListenerContainer(); listenerContainer.setConnectionFactory(connectionFactory); listenerContainer.setQueueNames(getRequestQueueName(serviceAPI)); listenerContainer.setMessageListener(listenerAdapter); if (this.concurentConsumers > 0) { listenerContainer.setConcurrentConsumers(concurentConsumers); } listenerContainer.start(); }
From source file:org.resthub.rpc.HessianEndpoint.java
/** * Starts the endpoint on the connection specified. * A listener container is launched on a created queue. The listener will * respond to hessian requests. The endpoint is closed by calling the destroy * method.// w ww . j av a 2 s . c o m */ public void run() { logger.debug("Launching endpoint for service : " + serviceAPI.getSimpleName()); admin = new RabbitAdmin(connectionFactory); // Add connectionListener to recreate queue when connection fall connectionFactory.addConnectionListener(new ConnectionListener() { public void onCreate(Connection connection) { createQueue(admin, getRequestQueueName(serviceAPI)); } public void onClose(Connection connection) { } }); // Create the queue normaly the first time this.createQueue(admin, getRequestQueueName(serviceAPI)); MessageListenerAdapter listenerAdapter = new MessageListenerAdapter( new RawMessageDelegate(serviceAPI, serviceImpl, serializerFactory)); listenerAdapter.setMessageConverter(null); listenerAdapter.setMandatoryPublish(false); listenerContainer = new SimpleMessageListenerContainer(); listenerContainer.setConnectionFactory(connectionFactory); listenerContainer.setQueueNames(getRequestQueueName(serviceAPI)); listenerContainer.setMessageListener(listenerAdapter); if (this.concurentConsumers > 0) { listenerContainer.setConcurrentConsumers(concurentConsumers); } listenerContainer.start(); }