Skip to content

Commit

Permalink
Allow the abstract text publisher to be configured to publish to many…
Browse files Browse the repository at this point in the history
… different sources.
  • Loading branch information
chenson42 committed Jul 11, 2008
1 parent d1607c8 commit 88fafd9
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 11 deletions.
Expand Up @@ -29,19 +29,18 @@
import org.jumpmind.symmetric.load.IDataLoaderContext;
import org.jumpmind.symmetric.load.IDataLoaderFilter;
import org.jumpmind.symmetric.model.IncomingBatchHistory;
import org.springframework.jms.core.JmsTemplate;

/**
* An abstract convenience class meant to be implemented by classes that need to
* publish JMS messages
* publish text messages
*/
abstract public class AbstractJmsPublisher implements IDataLoaderFilter, IBatchListener {
abstract public class AbstractTextPublisher implements IDataLoaderFilter, IBatchListener {

private static final Log logger = LogFactory.getLog(AbstractJmsPublisher.class);
private static final Log logger = LogFactory.getLog(AbstractTextPublisher.class);

private static final String msg_CACHE = "msg_CACHE";

protected JmsTemplate jmsTemplate;
protected IPublisher publisher;

private boolean loadDataInTargetDatabase = true;

Expand Down Expand Up @@ -114,9 +113,9 @@ private void finalizeAndPublish(IDataLoaderContext ctx) {
msg.append(addTextFooter(ctx));

if (logger.isDebugEnabled()) {
logger.debug("Sending Text to JMS -> " + msg);
logger.debug("publishing text message -> " + msg);
}
jmsTemplate.convertAndSend(msg.toString());
publisher.publish(msg.toString());
}
}

Expand All @@ -127,10 +126,6 @@ public void batchComplete(IDataLoader loader, IncomingBatchHistory hist) {
}
}

public void setJmsTemplate(JmsTemplate jmsTemplate) {
this.jmsTemplate = jmsTemplate;
}

public void setLoadDataInTargetDatabase(boolean loadDataInTargetDatabase) {
this.loadDataInTargetDatabase = loadDataInTargetDatabase;
}
Expand All @@ -139,4 +134,8 @@ public void setTableList(Set<String> tableList) {
this.tableList = tableList;
}

public void setPublisher(IPublisher publisher) {
this.publisher = publisher;
}

}
@@ -0,0 +1,5 @@
package org.jumpmind.symmetric.ext;

public interface IPublisher {
public void publish(String text);
}
@@ -0,0 +1,17 @@
package org.jumpmind.symmetric.ext;

import org.springframework.jms.core.JmsTemplate;

public class SimpleJmsPublisher implements IPublisher {

JmsTemplate jmsTemplate;

public void publish(String text) {
jmsTemplate.convertAndSend(text);
}

public void setJmsTemplate(JmsTemplate jmsTemplate) {
this.jmsTemplate = jmsTemplate;
}

}

0 comments on commit 88fafd9

Please sign in to comment.