Showing how to use @Listener to subscribe to an ActiveMQ queue in
Eclipse Dirigible.
sample-java-listener-decorator/ # Dirigible project (registry path)
└── demo/
└── listener/
├── OrderListener.java # @Listener — subscribes to "java-order-queue"
└── trigger.mjs # JS helper that sends a test message to the queue
Drop this project into the Dirigible IDE (clone via the Git perspective and publish, or copy it
to /registry/public/sample-java-listener-decorator/). The synchronizer compiles OrderListener.java
and registers the queue listener. Hit /services/js/sample-java-listener-decorator/demo/listener/trigger.mjs
to send a test message; the listener logs OrderListener received: … on receipt.
Two ways to write a Java listener — pick one per @Component class (never both), like Spring:
- Strong interface —
OrderListeneris a@Componentthat implementsMessageHandlerand supplies its owndestination()(likejakarta.jms.MessageListener); no@Listenerannotation. - Method-level annotation —
InvoiceListeneris a@Componentwith an@Listener-annotated method (Spring@JmsListenerstyle), using a constructor-injectedAuditorbean.
See the Develop guide and the Java SDK.