title: Sending object using spring boot JMS
body: <p>I made 2 classes : 1 to send and 1 to receive. Currently I can send just a basic string and it works well</p>
  
  <p>Sender</p>
  
  <pre><code>@Component
  public class Sender {
  
      @Autowired
      private JmsTemplate jmsTemplate;
  
      //Script must be serializable
      public void testSend(/*Script*/String message)
      {
          jmsTemplate.convertAndSend("my-destination", message);      
      }
  }
  </code></pre>
  
  <p>Receiver</p>
  
  <pre><code>@Component
  public class Receiver {
  
      @Autowired
      private ConfigurableApplicationContext context;
  
      @JmsListener(destination = "my-destination")
      public void receive(String message) {
          System.out.println(message);
  
          try {
              Thread.sleep(4000);
          } catch (InterruptedException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
          }
          context.close();
      }
  }
  </code></pre>
  
  <p>I can't implement proper code here, if someone can just show me how to do, I'd grateful</p>
  
  <p>I would make almost the same thing but to send complex java objects (serializable). And the reeceiver class should be able to recognize the class of the object.</p>