Package org.springframework.jms.support.converter

Examples of org.springframework.jms.support.converter.MessageConverter


      }
      else {
        messageListener.setDefaultResponseQueueName(responseDestination);
      }
    }
    MessageConverter messageConverter = container.getMessageConverter();
    if (messageConverter != null) {
      messageListener.setMessageConverter(messageConverter);
    }
    return messageListener;
  }
View Full Code Here


   * @return the JMS {@code Message} (never {@code null})
   * @throws JMSException if thrown by JMS API methods
   * @see #setMessageConverter
   */
  protected Message buildMessage(Session session, Object result) throws JMSException {
    MessageConverter converter = getMessageConverter();
    if (converter != null) {
      if (result instanceof org.springframework.messaging.Message) {
        return this.messagingMessageConverter.toMessage(result, session);
      }
      else {
        return converter.toMessage(result, session);
      }
    }
    else {
      if (!(result instanceof Message)) {
        throw new MessageConversionException(
View Full Code Here

  }

  @Test
  public void convertMessageConversionExceptionOnSend() throws JMSException {
    Message<String> message = createTextMessage();
    MessageConverter messageConverter = mock(MessageConverter.class);
    willThrow(org.springframework.jms.support.converter.MessageConversionException.class)
        .given(messageConverter).toMessage(eq(message), anyObject());
    messagingTemplate.setJmsMessageConverter(messageConverter);
    invokeMessageCreator("myQueue");
View Full Code Here

  }

  @Test
  public void convertMessageConversionExceptionOnReceive() throws JMSException {
    javax.jms.Message message = createJmsTextMessage();
    MessageConverter messageConverter = mock(MessageConverter.class);
    willThrow(org.springframework.jms.support.converter.MessageConversionException.class)
        .given(messageConverter).fromMessage(message);
    messagingTemplate.setJmsMessageConverter(messageConverter);
    given(jmsTemplate.receive("myQueue")).willReturn(message);
View Full Code Here

  }

  @Test
  public void convertMessageFormatException() throws JMSException {
    Message<String> message = createTextMessage();
    MessageConverter messageConverter = mock(MessageConverter.class);
    willThrow(MessageFormatException.class).given(messageConverter).toMessage(eq(message), anyObject());
    messagingTemplate.setJmsMessageConverter(messageConverter);
    invokeMessageCreator("myQueue");

    thrown.expect(org.springframework.messaging.converter.MessageConversionException.class);
View Full Code Here

  }

  @Test
  public void convertMessageNotWritableException() throws JMSException {
    Message<String> message = createTextMessage();
    MessageConverter messageConverter = mock(MessageConverter.class);
    willThrow(MessageNotWriteableException.class).given(messageConverter).toMessage(eq(message), anyObject());
    messagingTemplate.setJmsMessageConverter(messageConverter);
    invokeMessageCreator("myQueue");

    thrown.expect(org.springframework.messaging.converter.MessageConversionException.class);
View Full Code Here

   * @return the content of the message, to be passed into the
   * listener method as argument
   * @throws JMSException if thrown by JMS API methods
   */
  protected Object extractMessage(Message message) throws JMSException {
    MessageConverter converter = getMessageConverter();
    if (converter != null) {
      return converter.fromMessage(message);
    }
    return message;
  }
View Full Code Here

   * @return the JMS <code>Message</code> (never <code>null</code>)
   * @throws JMSException if thrown by JMS API methods
   * @see #setMessageConverter
   */
  protected Message buildMessage(Session session, Object result) throws JMSException {
    MessageConverter converter = getMessageConverter();
    if (converter != null) {
      return converter.toMessage(result, session);
    }
    else {
      if (!(result instanceof Message)) {
        throw new MessageConversionException(
            "No MessageConverter specified - cannot handle message [" + result + "]");
View Full Code Here

  public MessageConverter getMessageConverter() {
    return this.messageConverter;
  }

  private MessageConverter getRequiredMessageConverter() throws IllegalStateException {
    MessageConverter converter = getMessageConverter();
    if (converter == null) {
      throw new IllegalStateException("No 'messageConverter' specified. Check configuration of JmsTemplate.");
    }
    return converter;
  }
View Full Code Here

   * @return the content of the message, to be passed into the
   * listener method as argument
   * @throws JMSException if thrown by JMS API methods
   */
  protected Object extractMessage(Message message) throws JMSException {
    MessageConverter converter = getMessageConverter();
    if (converter != null) {
      return converter.fromMessage(message);
    }
    return message;
  }
View Full Code Here

TOP

Related Classes of org.springframework.jms.support.converter.MessageConverter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.