Skip to content

Commit

Permalink
Create the Java Message System Factory and Queue inside a producer. I…
Browse files Browse the repository at this point in the history
  • Loading branch information
poikilotherm committed Nov 30, 2020
1 parent 93c76b4 commit 743706c
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,13 @@
*
* @author Leonid Andreev
*/
@MessageDriven(mappedName = "jms/DataverseIngest", activationConfig = {@ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Auto-acknowledge"), @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue")})
@MessageDriven(
mappedName = "java:app/jms/queue/ingest",
activationConfig = {
@ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Auto-acknowledge"),
@ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue")
}
)
public class IngestMessageBean implements MessageListener {
private static final Logger logger = Logger.getLogger(IngestMessageBean.class.getCanonicalName());
@EJB DatasetServiceBean datasetService;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package edu.harvard.iq.dataverse.ingest;

import javax.annotation.Resource;
// https://www.baeldung.com/jee-cdi-vs-ejb-singleton
import javax.inject.Singleton;
import javax.enterprise.inject.Produces;
import javax.jms.JMSConnectionFactoryDefinition;
import javax.jms.JMSDestinationDefinition;
import javax.jms.Queue;
import javax.jms.QueueConnectionFactory;

@JMSConnectionFactoryDefinition(
description = "Dataverse Ingest Queue Factory",
name = "java:app/jms/factory/ingest",
resourceAdapter = "jmsra",
interfaceName = "javax.jms.QueueConnectionFactory",
maxPoolSize = 250,
minPoolSize = 1,
properties = {
"org.glassfish.connector-connection-pool.max-wait-time-in-millis=60000",
"org.glassfish.connector-connection-pool.pool-resize-quantity=2"
}
)
@JMSDestinationDefinition(
description = "Dataverse Ingest Queue",
name = "java:app/jms/queue/ingest",
resourceAdapter = "jmsra",
interfaceName="javax.jms.Queue",
destinationName = "DataverseIngest"
)
@Singleton
public class IngestQueueProducer {

@Resource(lookup="java:app/jms/queue/ingest")
Queue ingestQueue;

@Resource(lookup="java:app/jms/factory/ingest")
QueueConnectionFactory ingestQueueFactory;

@Produces
public Queue getIngestQueue() {
return ingestQueue;
}

@Produces
public QueueConnectionFactory getIngestQueueFactory() {
return ingestQueueFactory;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,9 @@ public class IngestServiceBean {
@EJB
SystemConfig systemConfig;

@Resource(mappedName = "jms/DataverseIngest")
@Resource(name = "java:app/jms/queue/ingest")
Queue queue;
@Resource(mappedName = "jms/IngestQueueConnectionFactory")
@Resource(name = "java:app/jms/factory/ingest")
QueueConnectionFactory factory;


Expand Down

0 comments on commit 743706c

Please sign in to comment.