[[Jakarta_Messaging_API]]
= Jakarta Messaging API

Coming Soon

[IMPORTANT]

This guide is still under development, check back soon!

[[configure-jbossas-for-messaging]]
== Configure WildFly for Messaging

Currently, the default configuration does not include the Jakarta Messaging subsystem.
To enable Jakarta Messaging in the standalone server you need to add these
configuration items to standalone.xml or simply use standalone-full.xml.

[source,java,options="nowrap"]
----
<extension module="org.jboss.as.messaging"/>
 
<subsystem xmlns="urn:jboss:domain:messaging:1.0">
    <!-- Default journal file size is 10Mb, reduced here to 100k for faster first boot -->
    <journal-file-size>102400</journal-file-size>
    <journal-min-files>2</journal-min-files>
    <journal-type>NIO</journal-type>
    <!-- disable messaging persistence -->
    <persistence-enabled>false</persistence-enabled>
 
    <connectors>
       <netty-connector name="netty" socket-binding="messaging" />
       <netty-connector name="netty-throughput" socket-binding="messaging-throughput">
          <param key="batch-delay" value="50"/>
       </netty-connector>
       <in-vm-connector name="in-vm" server-id="0" />
    </connectors>
 
    <acceptors>
       <netty-acceptor name="netty" socket-binding="messaging" />
       <netty-acceptor name="netty-throughput" socket-binding="messaging-throughput">
          <param key="batch-delay" value="50"/>
          <param key="direct-deliver" value="false"/>
       </netty-acceptor>
        <acceptor name="stomp-acceptor">
         <factory-class>org.hornetq.core.remoting.impl.netty.NettyAcceptorFactory</factory-class>
         <param key="protocol" value="stomp" />
         <param key="port" value="61613" />
       </acceptor>
       <in-vm-acceptor name="in-vm" server-id="0" />
    </acceptors>
 
    <security-settings>
       <security-setting match="#">
           <permission type="createNonDurableQueue" roles="guest"/>
           <permission type="deleteNonDurableQueue" roles="guest"/>
            <permission type="consume" roles="guest"/>
            <permission type="send" roles="guest"/>
       </security-setting>
    </security-settings>
 
    <address-settings>
       <!--default for catch all-->
       <address-setting match="#">
          <dead-letter-address>jms.queue.DLQ</dead-letter-address>
          <expiry-address>jms.queue.ExpiryQueue</expiry-address>
          <redelivery-delay>0</redelivery-delay>
          <max-size-bytes>10485760</max-size-bytes>
          <message-counter-history-day-limit>10</message-counter-history-day-limit>
          <address-full-policy>BLOCK</address-full-policy>
       </address-setting>
    </address-settings>
 
    <!--JMS Stuff-->
   <jms-connection-factories>
      <connection-factory name="InVmConnectionFactory">
         <connectors>
            <connector-ref connector-name="in-vm"/>
         </connectors>
         <entries>
            <entry name="java:/ConnectionFactory"/>
         </entries>
      </connection-factory>
      <connection-factory name="RemoteConnectionFactory">
         <connectors>
            <connector-ref connector-name="netty"/>
         </connectors>
         <entries>
            <entry name="RemoteConnectionFactory"/>
         </entries>
      </connection-factory>
      <pooled-connection-factory name="hornetq-ra">
         <transaction mode="xa"/>
         <connectors>
            <connector-ref connector-name="in-vm"/>
         </connectors>
         <entries>
            <entry name="java:/JmsXA"/>
            <!-- Global JNDI entry used to provide a default JMS Connection factory to EE application -->
            <entry name="java:jboss/DefaultJMSConnectionFactory"/>
         </entries>
      </pooled-connection-factory>
   </jms-connection-factories>
 
   <jms-destinations>
      <jms-queue name="testQueue">
         <entry name="queue/test"/>
      </jms-queue>
      <jms-topic name="testTopic">
         <entry name="topic/test"/>
      </jms-topic>
   </jms-destinations>
</subsystem>
 
<socket-binding name="messaging" port="5445" />
<socket-binding name="messaging-throughput" port="5455"/>
----

Alternatively run the server using the 'full' or 'full-ha' configuration

[source,java,options="nowrap"]
----
$ bin/standalone.sh --server-config=standalone-full.xml
----

[[adding-the-message-destinations]]
== Adding the message destinations

For this tutorial we use two message destinations

* BidQueue - The queue that receives the client bids
* AuctionTopic - The topic that publishes the start of a new auction

You can either add the message destinations by using the Command Line
Interface (CLI)

[source,java,options="nowrap"]
----
$ bin/jboss-cli.sh --connect
Connected to standalone controller at localhost:9999
[standalone@localhost:9999 /] jms-queue add --queue-address=BidQueue --entries=queue/bid
[standalone@localhost:9999 /] jms-topic add --topic-address=AuctionTopic --entries=topic/auction
[standalone@localhost:9999 /] exit
Closed connection to localhost:9999
----

or by adding them to the subsytem configuration as shown above.
