@Override public void trigger(Message<?> message) { Object key = this.correlationStrategy.getCorrelationKey(message); if (key == null) { throw new MessagingException(message, "Correlation Strategy returned null"); } SynchronousQueue<Message<?>> syncQueue = createOrObtainQueue(key); try { if (!syncQueue.offer(message, this.timeout, TimeUnit.MILLISECONDS)) { this.logger.error("Suspending thread timed out or did not arrive within timeout for: " + message); this.suspensions.remove(key); if (getDiscardChannel() != null) { this.messagingTemplate.send(getDiscardChannel(), message); } } } catch (InterruptedException e) { Thread.currentThread().interrupt(); this.logger.error("Interrupted while waiting for the suspending thread for: " + message); this.suspensions.remove(key); } }
@Test public void parserFieldPopulationTests() { BarrierMessageHandler handler = TestUtils.getPropertyValue(this.barrier1, "handler", BarrierMessageHandler.class); assertEquals(10000L, TestUtils.getPropertyValue(handler, "timeout")); assertTrue(TestUtils.getPropertyValue(handler, "requiresReply", Boolean.class)); assertThat(TestUtils.getPropertyValue(this.barrier2, "handler.correlationStrategy"), instanceOf(HeaderAttributeCorrelationStrategy.class)); assertThat(TestUtils.getPropertyValue(this.barrier3, "handler.messageGroupProcessor"), instanceOf(TestMGP.class)); assertThat(TestUtils.getPropertyValue(this.barrier3, "handler.correlationStrategy"), instanceOf(TestCS.class)); assertSame(handler.getDiscardChannel(), this.discards); }
@Override public void trigger(Message<?> message) { Object key = this.correlationStrategy.getCorrelationKey(message); if (key == null) { throw new MessagingException(message, "Correlation Strategy returned null"); } SynchronousQueue<Message<?>> syncQueue = createOrObtainQueue(key); try { if (!syncQueue.offer(message, this.timeout, TimeUnit.MILLISECONDS)) { this.logger.error("Suspending thread timed out or did not arrive within timeout for: " + message); this.suspensions.remove(key); if (getDiscardChannel() != null) { this.messagingTemplate.send(getDiscardChannel(), message); } } } catch (InterruptedException e) { Thread.currentThread().interrupt(); this.logger.error("Interrupted while waiting for the suspending thread for: " + message); this.suspensions.remove(key); } }