Setting up Notifications Using Apache ActiveMQ
Installation of Apache ActiveMQ Artemis
The first step in the installation of the message service is to download and extract the ActiveMQ Artemis distribution. The software can be downloaded from https://activemq.apache.org/artemis/download.html and we currently recommend version 2.9.0. You can extract the contents of the downloaded archive anywhere you have space in your filesystem but we recommend that you keep the distribution of the Artemis software separate from the directory where you have OpenEMPI installed. This will allow you to upgrade to future version of OpenEMPI and Artemis software independently of the instance of OpenEMPI you are maintaining.
The next step is to create an instance of the messaging server or broker. In the following example we assume that the environment variable ARTEMIS_HOME points to the directory where you extracted the contents of the ActiveMQ Artemis software and OPENEMPI_HOME points to the directory where you have OpenEMPI installed.
 $ ${ARTEMIS_HOME}/bin/artemis create ${OPENEMPI_HOME}/artemis --user openempi \ --password openempi --require-login Creating ActiveMQ Artemis instance at: /sysnet/openempi/artemis Auto tuning journal ... done! Your system can make 0.53 writes per millisecond, your journal-buffer-timeout will be 1900000 You can now start the broker by executing: "/sysnet/openempi/artemis/bin/artemis" run Or you can run the broker in the background using: "/sysnet/openempi/artemis/bin/artemis-service" start
Once the broker has been created, you can start it using the commands shown above by the broker after it starts.
$ /sysnet/projects/3.5.x/openempi/artemis/bin/artemis run _ _ _ / \ ____| |_ ___ __ __(_) _____ / _ \| _ \ __|/ _ \ \/ | |/ __/ / ___ \ | \/ |_/ __/ |\/| | |\___ \ /_/ \_\| \__\____|_| |_|_|/___ / Apache ActiveMQ Artemis 2.1.0 17:46:00,904 INFO [org.apache.activemq.artemis.integration.bootstrap] AMQ101000: Starting ActiveMQ Artemis Server 17:46:00,936 INFO [org.apache.activemq.artemis.core.server] AMQ221000: live Message Broker is starting with configuration Broker Configuration (clustered=false,journalDirectory=./data/journal,bindingsDirectory=./data/bindings, largeMessagesDirectory=./data/large-messages,pagingDirectory=./data/paging) 17:46:00,953 INFO [org.apache.activemq.artemis.core.server] AMQ221012: Using AIO Journal 17:46:00,978 INFO [org.apache.activemq.artemis.core.server] AMQ221057: Global Max Size is being adjusted to 1/2 of the JVM max size (-Xmx). being defined as 1,073,741,824 17:46:00,992 INFO [org.apache.activemq.artemis.core.server] AMQ221043: Protocol module found: [artemis-server]. Adding protocol support for: CORE 17:46:00,992 INFO [org.apache.activemq.artemis.core.server] AMQ221043: Protocol module found: [artemis-amqp-protocol]. Adding protocol support for: AMQP 17:46:00,993 INFO [org.apache.activemq.artemis.core.server] AMQ221043: Protocol module found: [artemis-hornetq-protocol]. Adding protocol support for: HORNETQ 17:46:00,993 INFO [org.apache.activemq.artemis.core.server] AMQ221043: Protocol module found: [artemis-mqtt-protocol]. Adding protocol support for: MQTT 17:46:00,993 INFO [org.apache.activemq.artemis.core.server] AMQ221043: Protocol module found: [artemis-openwire-protocol]. Adding protocol support for: OPENWIRE 17:46:00,995 INFO [org.apache.activemq.artemis.core.server] AMQ221043: Protocol module found: [artemis-stomp-protocol]. Adding protocol support for: STOMP 17:46:01,031 INFO [org.apache.activemq.artemis.core.server] AMQ221034: Waiting indefinitely to obtain live lock 17:46:01,031 INFO [org.apache.activemq.artemis.core.server] AMQ221035: Live Server Obtained live lock 17:46:01,329 INFO [org.apache.activemq.artemis.core.server] AMQ221003: Deploying queue DLQ 17:46:01,403 INFO [org.apache.activemq.artemis.core.server] AMQ221003: Deploying queue ExpiryQueue 17:46:01,695 INFO [org.apache.activemq.artemis.core.server] AMQ221020: Started EPOLL Acceptor at 0.0.0.0:61616 for protocols [CORE,MQTT,AMQP,STOMP,HORNETQ,OPENWIRE] 17:46:01,697 INFO [org.apache.activemq.artemis.core.server] AMQ221020: Started EPOLL Acceptor at 0.0.0.0:5445 for protocols [HORNETQ,STOMP] 17:46:01,698 INFO [org.apache.activemq.artemis.core.server] AMQ221020: Started EPOLL Acceptor at 0.0.0.0:5672 for protocols [AMQP] 17:46:01,736 INFO [org.apache.activemq.artemis.core.server] AMQ221020: Started EPOLL Acceptor at 0.0.0.0:1883 for protocols [MQTT] 17:46:01,738 INFO [org.apache.activemq.artemis.core.server] AMQ221020: Started EPOLL Acceptor at 0.0.0.0:61613 for protocols [STOMP] 17:46:01,749 INFO [org.apache.activemq.artemis.core.server] AMQ221007: Server is now live 17:46:01,750 INFO [org.apache.activemq.artemis.core.server] AMQ221001: Apache ActiveMQ Artemis Message Broker version 2.1.0 [0.0.0.0, nodeID=1e044172-8b71-11e7-beca-005056c00008] 17:46:02,082 INFO [org.apache.activemq.artemis] AMQ241001: HTTP Server started at http://localhost:8161 17:46:02,082 INFO [org.apache.activemq.artemis] AMQ241002: Artemis Jolokia REST API available at http://localhost:8161/jolokia 17:46:06,620 WARN [org.apache.activemq.artemis.core.server] AMQ222210: Storage usage is beyond max-disk-usage. System will start blocking producers. 17:46:26,912 INFO [org.apache.activemq.artemis.core.server] AMQ221002: Apache ActiveMQ Artemis Message Broker version 2.1.0 [1e044172-8b71-11e7-beca-005056c00008] stopped, uptime 26.007 seconds
You now need to configure OpenEMPI to specify how it should connect to the broker during startup. After stopping the OpenEMPI service you need to perform two configuration changes. The first configuration change requires adding the following three parameters:
- The URL that OpenEMPI should use to connect to the running broker (using the parameter brokerUrl).
- The username that OpenEMPI should use to connect to the broker (using the parameter brokerUsername).
- The password that OpenEMPI should use to connect to the broker (using the parameter brokerPassword).
All three parameters are specified in the applicationContext-resources.xml file as shown below. The brokerUsername and brokerPassword must match the values used during the creation of the broker above. The listening hostname, port number and many other configuration parameters for the broken can be specified in the broker.xml file that was created in the etc directory of the broker instance you created above.
<property name="properties"> <props> <!-- Default value for properties that are optional --> <prop key="assigning-authority-id"></prop> <prop key="admin-user-username">admin</prop> <prop key="admin-user-password">admin</prop> <!-- Parameters added to support Apache Artemis ActiveMQ messaging --> <prop key="brokerUrl">tcp://localhost:61616</prop> <prop key="brokerUsername">openempi</prop> <prop key="brokerPassword">openempi</prop> </props> </property>
The second step is to deactivate the default notification service since you are replacing it with the Artemis-based version. To do that, simply change the name of the default notification service from "notificationService" to "notificationServiceDefault" as shown below.
<!-- Default notification service that doesn't do much --> <bean id="notificationServiceDefault" class="org.openhie.openempi.notification.impl.DefaultNotificationService"> </bean>
These two configuration changes will allow OpenEMPI when started to deliver messages to the Artemis broker. OpenEMPI will deliver messages for the following events into the topic corresponding to the event. You can then develop a consumer to connect to the broker and receive any of the messages that are of interest. The following table lists the name of each event and the name of the topic to which events of that type are delivered to the topic.
Â
Event Type | Topic Name |
---|---|
Add record event | add.event.topic |
Delete record event | delete.event.topic |
Import record event | import.event.topic |
Merge record event | merge.event.topic |
Update record event | update.event.topic |
Global Identifier Update event | identifierupdate.event.topic |
Â
Â