<div>My subscriber appears to timeout and not process any messages if the publisher takes a long time to initiate. (e.g. I start the publisher 30 minutes after the subscriber).</div><div>Is there a way to change this?</div><div><br></div><div>Appreciate any help as this is causing all kinds of problems!</div><div><br></div><div><br></div><div>public class RabbitMqSubscriber&lt;T extends Serializable&gt; implements Subscriber&lt;T&gt; {</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>private static final Logger log = LoggerFactory.getLogger(RabbitMqSubscriber.class);</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>private QueueingConsumer consumer;</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>private MessageListener&lt;T&gt; listener;</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>private String exchange;</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>private String topic;</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>public RabbitMqSubscriber(String host,String exchange,String topic) throws IOException {</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>this.exchange=exchange;</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>this.topic=topic;</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>ConnectionFactory factory = new ConnectionFactory();</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>factory.setHost(host);</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>Connection connection = factory.newConnection();</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>Channel channel = connection.createChannel();</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>channel.exchangeDeclare(exchange, "topic");</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>String queueName = channel.queueDeclare().getQueue();</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>channel.queueBind(queueName, exchange, topic);</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>consumer = new QueueingConsumer(channel);</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>channel.basicConsume(queueName, true, consumer);</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>}</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>public void run() {</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>log.info("Starting subscribing to messages on exchange: "+exchange + " with topic: "+topic);</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>while (true) {</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>QueueingConsumer.Delivery delivery;</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>try {</div><div><span class="Apple-tab-span" style="white-space:pre">                                </span>delivery = consumer.nextDelivery();</div><div><span class="Apple-tab-span" style="white-space:pre">                                </span>Object o=SerializationUtils.deserialize(delivery.getBody());</div><div><span class="Apple-tab-span" style="white-space:pre">                                </span>log.info("Subscriber received object: "+o);</div><div><span class="Apple-tab-span" style="white-space:pre">                                </span>listener.receive((T)o);</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>} catch (ShutdownSignalException | ConsumerCancelledException | InterruptedException e) {</div><div><span class="Apple-tab-span" style="white-space:pre">                                </span>throw new RuntimeException(e);</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>}</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>}</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>}</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>@Override</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>public void setListener(MessageListener&lt;T&gt; listener) {</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>this.listener=listener;</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>}</div><div>}</div><div><br></div><div><div>public class RabbitMqPublisher&lt;T extends Serializable&gt; implements Publisher&lt;T&gt;{</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>private String topic;</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>private Channel channel;</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>private String exchange;</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>private static final Logger log = LoggerFactory.getLogger(RabbitMqPublisher.class);</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>public RabbitMqPublisher(String host,String exchange,String topic) throws IOException {</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>super();</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>this.topic = topic;</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>this.exchange=exchange;</div><div><span class="Apple-tab-span" style="white-space:pre">        </span> &nbsp; &nbsp;ConnectionFactory factory = new ConnectionFactory();</div><div><span class="Apple-tab-span" style="white-space:pre">        </span> &nbsp; &nbsp;factory.setHost(host);</div><div><span class="Apple-tab-span" style="white-space:pre">        </span> &nbsp; &nbsp;Connection connection = factory.newConnection();</div><div><span class="Apple-tab-span" style="white-space:pre">        </span> &nbsp; &nbsp;channel = connection.createChannel();</div><div>&nbsp; &nbsp; &nbsp; &nbsp; channel.exchangeDeclare(exchange, "topic");</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>log.info("Publishing to messages on exchange: "+exchange + " with topic: "+topic);</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>}</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>@Override</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>public void publish(T t) {</div><div><span class="Apple-tab-span" style="white-space:pre">        </span> &nbsp; &nbsp;try {</div><div><span class="Apple-tab-span" style="white-space:pre">        </span> &nbsp; &nbsp;<span class="Apple-tab-span" style="white-space:pre">        </span>log.info("Publishing object: "+t);</div><div><span class="Apple-tab-span" style="white-space:pre">        </span> &nbsp; &nbsp; &nbsp; &nbsp;channel.basicPublish(exchange, topic, null, SerializationUtils.serialize(t));</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>} catch (IOException e) {</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>throw new RuntimeException(e);</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>}</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>}</div><div>}</div></div><div><br></div><div><div>public class TimeoutTest {</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>private static final Logger log = LoggerFactory.getLogger(TimeoutTest.class);</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>public static void main(String[] args) throws Exception{</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>final RabbitMqPublisher&lt;String&gt; publisher=new RabbitMqPublisher&lt;String&gt;("31.222.170.242","EXCHANGE","TEST");</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>final RabbitMqSubscriber&lt;String&gt; subscriber=new RabbitMqSubscriber&lt;String&gt;("31.222.170.242","EXCHANGE", "TEST");</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>subscriber.setListener(new MessageListener&lt;String&gt;() {</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span></div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>@Override</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>public void receive(String s) {</div><div><span class="Apple-tab-span" style="white-space:pre">                                </span>System.out.println("Received: "+s); //NEVER GETS CALLED!!!</div><div><span class="Apple-tab-span" style="white-space:pre">                                </span></div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>}</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>});</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>Executors.newSingleThreadExecutor().execute(new Runnable() {</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>public void run() {</div><div><span class="Apple-tab-span" style="white-space:pre">                                </span>subscriber.run();</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>}</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>});</div><div><span class="Apple-tab-span" style="white-space:pre">                </span></div><div><span class="Apple-tab-span" style="white-space:pre">                </span>//start subscriber then wait 30 minutes before publishing first message&nbsp;</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>Thread.sleep(1000*1800);</div><div><span class="Apple-tab-span" style="white-space:pre">                </span></div><div><span class="Apple-tab-span" style="white-space:pre">                </span>publisher.publish("MESSAGE PUBLISHED");</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>}</div><div><span class="Apple-tab-span" style="white-space:pre">        </span></div><div>}</div></div><div><br></div>