Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Open Subsurface Data Universe Software
Platform
System
Lib
cloud
ibm
OS Core Lib IBM
Commits
7268eab2
Commit
7268eab2
authored
May 11, 2022
by
Bhushan Rade
Browse files
Merge branch 'enable-topic' into 'master'
pub sub model implemented See merge request
!48
parents
f50cb9d7
438114e1
Pipeline
#107757
passed with stages
in 4 minutes and 43 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/main/java/org/opengroup/osdu/core/ibm/messagebus/ActiveMQFactory.java
View file @
7268eab2
...
...
@@ -8,16 +8,19 @@ import java.util.HashSet;
import
java.util.Set
;
import
javax.annotation.PostConstruct
;
import
javax.inject.Inject
;
import
javax.jms.Connection
;
import
javax.jms.ConnectionFactory
;
import
javax.jms.Session
;
import
org.apache.http.HttpStatus
;
import
org.opengroup.osdu.core.common.model.http.AppException
;
import
org.opengroup.osdu.core.common.model.http.DpsHeaders
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnProperty
;
import
org.springframework.context.annotation.Lazy
;
import
org.springframework.jms.JmsException
;
import
org.springframework.jms.core.JmsTemplate
;
...
...
@@ -35,6 +38,9 @@ public class ActiveMQFactory implements IMessageFactory {
@Autowired
public
JmsTemplate
jmsTemplate
;
@Autowired
DpsHeaders
header
;
private
Set
<
String
>
existingQueues
=
new
HashSet
<
String
>();
@PostConstruct
...
...
@@ -62,6 +68,9 @@ public class ActiveMQFactory implements IMessageFactory {
public
void
sendMessage
(
String
msg
)
{
sendMessage
(
DEFAULT_QUEUE_NAME
,
msg
,
-
1L
);
sendMessage
(
DEFAULT_QUEUE_COPY_NAME
,
msg
,
-
1L
);
// For WKE
//sending Message to topic
String
topicName
=
prefix
+
"-"
+
header
.
getPartitionId
()
+
"-"
+
INDEXER_QUEUE_NAME
+
"-topic"
;
sendMessageToTopic
(
topicName
,
msg
,
-
1L
);
}
@Override
...
...
@@ -122,5 +131,19 @@ public class ActiveMQFactory implements IMessageFactory {
return
queueNameWithPrefix
;
}
public
void
sendMessageToTopic
(
String
topicName
,
String
msg
,
Long
delay
)
{
try
{
jmsTemplate
.
setDeliveryDelay
(
delay
);
jmsTemplate
.
setPubSubDomain
(
true
);
jmsTemplate
.
convertAndSend
(
topicName
,
msg
);
logger
.
info
(
"[xx] Sent '"
+
msg
+
"' to topic ["
+
topicName
+
"] with delay "
+
delay
);
}
catch
(
JmsException
e
)
{
logger
.
error
(
"Failed to publish status."
+
" topic name ["
+
topicName
+
"]"
);
logger
.
error
(
e
.
getMessage
(),
e
);
e
.
printStackTrace
();
}
}
}
\ No newline at end of file
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment