{"id":2247,"date":"2021-07-17T15:01:19","date_gmt":"2021-07-17T06:01:19","guid":{"rendered":"https:\/\/www.skyer9.pe.kr\/wordpress\/?p=2247"},"modified":"2021-07-17T15:13:37","modified_gmt":"2021-07-17T06:13:37","slug":"jms-%eb%a5%bc-%ec%9d%b4%ec%9a%a9%ed%95%9c-%eb%a9%94%ec%8b%9c%ec%a7%95","status":"publish","type":"post","link":"https:\/\/www.skyer9.pe.kr\/wordpress\/?p=2247","title":{"rendered":"JMS \ub97c \uc774\uc6a9\ud55c \uba54\uc2dc\uc9d5"},"content":{"rendered":"<h1>JMS \ub97c \uc774\uc6a9\ud55c \uba54\uc2dc\uc9d5<\/h1>\n<h2>\ubaa9\ud45c<\/h2>\n<p>activemq \ub97c \uc774\uc6a9\ud574, \uba54\uc2dc\uc9d5 \uc2dc\uc2a4\ud15c\uc744 \uad6c\uc131\ud569\ub2c8\ub2e4.<\/p>\n<h2>\ud504\ub85c\uc81d\ud2b8 \uc0dd\uc131<\/h2>\n<p>\uc2e0\uaddc \ud504\ub85c\uc81d\ud2b8\ub97c \uc0dd\uc131\ud569\ub2c8\ub2e4.<\/p>\n<p>\uc758\uc874\uc131\uc740 DevTools, Lombok, Spring for Apache ActiveMQ 5 \uc744 \uc120\ud0dd\ud569\ub2c8\ub2e4.<\/p>\n<h2>Message Receiver \uc0dd\uc131<\/h2>\n<p>Email.java \ub97c \uc0dd\uc131\ud569\ub2c8\ub2e4.<\/p>\n<pre><code class=\"language-java\">public class Email {\n\n    private String to;\n    private String body;\n\n    public Email() {\n    }\n\n    public Email(String to, String body) {\n        this.to = to;\n        this.body = body;\n    }\n\n    public String getTo() {\n        return to;\n    }\n\n    public void setTo(String to) {\n        this.to = to;\n    }\n\n    public String getBody() {\n        return body;\n    }\n\n    public void setBody(String body) {\n        this.body = body;\n    }\n\n    @Override\n    public String toString() {\n        return String.format(&quot;Email{to=%s, body=%s}&quot;, getTo(), getBody());\n    }\n}<\/code><\/pre>\n<p>Receiver.java \ub97c \uc0dd\uc131\ud569\ub2c8\ub2e4.<\/p>\n<pre><code class=\"language-java\">@Component\npublic class Receiver {\n\n    @JmsListener(destination = &quot;mailbox&quot;, containerFactory = &quot;myFactory&quot;)\n    public void receiveMessage(Email email) {\n        System.out.println(&quot;Received &lt;&quot; + email + &quot;&gt;&quot;);\n    }\n}<\/code><\/pre>\n<h2>\uba54\uc2dc\uc9c0 \uc1a1\uc218\uc2e0<\/h2>\n<p>Application \ud074\ub798\uc2a4\uc5d0\uc11c \uba54\uc2dc\uc9c0\ub97c \uc1a1\uc2e0\ud558\uace0, \uc218\uc2e0\ub418\ub294 \ub0b4\uc6a9\uc774 \ub85c\uadf8\uc5d0 \ucd9c\ub825\ub418\ub294 \uac83\uc744 \ud655\uc778\ud560 \uc218 \uc788\uc2b5\ub2c8\ub2e4.<\/p>\n<pre><code class=\"language-java\">@SpringBootApplication\n@EnableJms\npublic class JmsApplication {\n\n    public static void main(String[] args) {\n\n        \/\/ Launch the application\n        ConfigurableApplicationContext context = SpringApplication.run(JmsApplication.class, args);\n\n        JmsTemplate jmsTemplate = context.getBean(JmsTemplate.class);\n\n        \/\/ Send a message with a POJO - the template reuse the message converter\n        System.out.println(&quot;Sending an email message.&quot;);\n        jmsTemplate.convertAndSend(&quot;mailbox&quot;, new Email(&quot;info@example.com&quot;, &quot;Hello&quot;));\n    }\n\n    @Bean\n    public JmsListenerContainerFactory&lt;?&gt; myFactory(ConnectionFactory connectionFactory,\n                                                    DefaultJmsListenerContainerFactoryConfigurer configurer) {\n\n        DefaultJmsListenerContainerFactory factory = new DefaultJmsListenerContainerFactory();\n        \/\/ This provides all boot&#039;s default to this factory, including the message converter\n        configurer.configure(factory, connectionFactory);\n        \/\/ You could still override some of Boot&#039;s default if necessary.\n        return factory;\n    }\n\n    @Bean \/\/ Serialize message content to json using TextMessage\n    public MessageConverter jacksonJmsMessageConverter() {\n        MappingJackson2MessageConverter converter = new MappingJackson2MessageConverter();\n        converter.setTargetType(MessageType.TEXT);\n        converter.setTypeIdPropertyName(&quot;_type&quot;);\n        return converter;\n    }\n}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>JMS \ub97c \uc774\uc6a9\ud55c \uba54\uc2dc\uc9d5 \ubaa9\ud45c activemq \ub97c \uc774\uc6a9\ud574, \uba54\uc2dc\uc9d5 \uc2dc\uc2a4\ud15c\uc744 \uad6c\uc131\ud569\ub2c8\ub2e4. \ud504\ub85c\uc81d\ud2b8 \uc0dd\uc131 \uc2e0\uaddc \ud504\ub85c\uc81d\ud2b8\ub97c \uc0dd\uc131\ud569\ub2c8\ub2e4. \uc758\uc874\uc131\uc740 DevTools, Lombok, Spring for Apache ActiveMQ 5 \uc744 \uc120\ud0dd\ud569\ub2c8\ub2e4. Message Receiver \uc0dd\uc131 Email.java \ub97c \uc0dd\uc131\ud569\ub2c8\ub2e4. public class Email { private String to; private String body; public Email() { } public Email(String to, String body) { this.to = to;\u2026 <span class=\"read-more\"><a href=\"https:\/\/www.skyer9.pe.kr\/wordpress\/?p=2247\">Read More &raquo;<\/a><\/span><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[29],"tags":[],"class_list":["post-2247","post","type-post","status-publish","format-standard","hentry","category-spring-boot-2-5"],"_links":{"self":[{"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/2247","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2247"}],"version-history":[{"count":2,"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/2247\/revisions"}],"predecessor-version":[{"id":2249,"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/2247\/revisions\/2249"}],"wp:attachment":[{"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2247"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2247"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2247"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}