I am going to explain how to configure a command as topic messaging in ATG framework.
The following command would be issues which invoke atg component MyTestComponent.
C:\pkp>curl -u "admin:admin" -d "invokeMethod=invalidate&submit=Invoke+Method" "http://lcalhost/dyn/admin/nucleus/com/test/common/messaging/MyTestComponent/"
Now, I am going to create topic message for component MyTestComponent.
Step 1: Create component:
MyTestComponent.properties
$class=com.test.common.messaging.MyTestComponent
myMesseage=GetCrawlData
public class MyTestComponent extends GenericService implements MessageSource{
public void invalidate() throws JMSException{
objectMessage = getMessageSourceContext().createObjectMessage(getMyMesseaget());
getMessageSourceContext().sendMessage(getMyMesseaget(),objectMessage);
}
This component create & send message to topic.
Step 2:
Define topic & queue
\common\config\atg\dynamo\messaging\SqlJmsProvider.properties
requiredQueueNames+=\
sqldms/test/MyQueue1,\
sqldms/test/MyQueue2,\
requiredTopicNames+=\
sqldms/test/MyTopic1,\
sqldms/MyTopic
Step 3:
The topic & queue message can be seen in table under core schema
select * from dms_topic;
select * from dms_queue;
Step 4:
/atg/dynamo/messaging/MessagingManager/
doStartService - start the service
definitionFile
CONFIGPATH filename /atg/dynamo/messaging/dynamoMessagingSystem.xml
/atg/scenario/ScenarioManager/
definitionFile
CONFIGPATH filename /atg/scenario/scenarioManager.xml
Step 5:
\common\config\atg\dynamo\messaging\dynamoMessagingSystem.xml
<?xml version="1.0" encoding="ISO-8859-1" ?>
<dynamo-message-system>
<patchbay>
<message-source>
<nucleus-name>/com/test/common/messaging/MyTestComponent </nucleus-name>
<output-port>
<port-name>GetCrawlData</port-name>
<output-destination>
<provider-name>sqldms</provider-name>
<destination-name>patchbay:/sqldms/MyTopic</destination-name>
<destination-type>Topic</destination-type>
</output-destination>
</output-port>
</message-source>
<message-sink>
<nucleus-name>/com/test/common/messaging/MyTopicSink</nucleus-name>
<input-port>
<port-name>GetCrawlData</port-name>
<input-destination>
<destination-name>patchbay:/sqldms/MyTopic</destination-name>
<destination-type>Topic</destination-type>
</input-destination>
</input-port>
</message-sink>
</patchbay>
</dynamo-message-system>
Step 6:
Create message sing nucleus component
MyTopicSink.properties
myCrawler=/com/test/MyCralwer
MyTopicSink.java
public class MyTopicSink extends GenericDataListenerService implements MessageSink {
public synchronized void receiveMessage(String pPortName, Message pMessage)
throws JMSException {
getMyCralwer().CrawlData();
}
The following command would be issues which invoke atg component MyTestComponent.
C:\pkp>curl -u "admin:admin" -d "invokeMethod=invalidate&submit=Invoke+Method" "http://lcalhost/dyn/admin/nucleus/com/test/common/messaging/MyTestComponent/"
Now, I am going to create topic message for component MyTestComponent.
Step 1: Create component:
MyTestComponent.properties
$class=com.test.common.messaging.MyTestComponent
myMesseage=GetCrawlData
public class MyTestComponent extends GenericService implements MessageSource{
public void invalidate() throws JMSException{
objectMessage = getMessageSourceContext().createObjectMessage(getMyMesseaget());
getMessageSourceContext().sendMessage(getMyMesseaget(),objectMessage);
}
This component create & send message to topic.
Step 2:
Define topic & queue
\common\config\atg\dynamo\messaging\SqlJmsProvider.properties
requiredQueueNames+=\
sqldms/test/MyQueue1,\
sqldms/test/MyQueue2,\
requiredTopicNames+=\
sqldms/test/MyTopic1,\
sqldms/MyTopic
Step 3:
The topic & queue message can be seen in table under core schema
select * from dms_topic;
select * from dms_queue;
Step 4:
/atg/dynamo/messaging/MessagingManager/
doStartService - start the service
definitionFile
CONFIGPATH filename /atg/dynamo/messaging/dynamoMessagingSystem.xml
/atg/scenario/ScenarioManager/
definitionFile
CONFIGPATH filename /atg/scenario/scenarioManager.xml
Step 5:
\common\config\atg\dynamo\messaging\dynamoMessagingSystem.xml
<?xml version="1.0" encoding="ISO-8859-1" ?>
<dynamo-message-system>
<patchbay>
<message-source>
<nucleus-name>/com/test/common/messaging/MyTestComponent </nucleus-name>
<output-port>
<port-name>GetCrawlData</port-name>
<output-destination>
<provider-name>sqldms</provider-name>
<destination-name>patchbay:/sqldms/MyTopic</destination-name>
<destination-type>Topic</destination-type>
</output-destination>
</output-port>
</message-source>
<message-sink>
<nucleus-name>/com/test/common/messaging/MyTopicSink</nucleus-name>
<input-port>
<port-name>GetCrawlData</port-name>
<input-destination>
<destination-name>patchbay:/sqldms/MyTopic</destination-name>
<destination-type>Topic</destination-type>
</input-destination>
</input-port>
</message-sink>
</patchbay>
</dynamo-message-system>
Step 6:
Create message sing nucleus component
MyTopicSink.properties
myCrawler=/com/test/MyCralwer
MyTopicSink.java
public class MyTopicSink extends GenericDataListenerService implements MessageSink {
public synchronized void receiveMessage(String pPortName, Message pMessage)
throws JMSException {
getMyCralwer().CrawlData();
}
Can i specify the acknowledgement mode in dynamomessaging.xml file?
ReplyDeleteRespect and I have a swell proposal: Who Repairs House Foundations home renovation designers
ReplyDelete