Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
Component Sharing
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
CI / CD Analytics
Repository Analytics
Value Stream Analytics
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Gagandeep Singh Bhatia
Component Sharing
Commits
66bce212
Commit
66bce212
authored
May 03, 2024
by
Rahul Panvalkar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Upload New File
parent
c745fa65
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
129 additions
and
0 deletions
+129
-0
Rahul/framework/JMSSender.java
Rahul/framework/JMSSender.java
+129
-0
No files found.
Rahul/framework/JMSSender.java
0 → 100644
View file @
66bce212
package
ibase
.
webitm
.
utility
;
import
javax.jms.JMSException
;
import
javax.jms.Queue
;
import
javax.jms.QueueConnection
;
import
javax.jms.QueueConnectionFactory
;
import
javax.jms.QueueSender
;
import
javax.jms.QueueSession
;
import
javax.jms.TextMessage
;
import
javax.naming.InitialContext
;
import
javax.naming.NamingException
;
import
org.apache.activemq.artemis.api.jms.ActiveMQJMSConstants
;
import
ibase.utility.CommonConstants
;
import
ibase.utility.E12GenericUtility
;
import
ibase.utility.UserInfoBean
;
public
class
JMSSender
{
public
final
static
String
JMS_USERNAME
=
CommonConstants
.
JMS_USERNAME
;
// The role for this user is "guest" in ApplicationRealm
public
final
static
String
JMS_PASSWORD
=
CommonConstants
.
JMS_PASSWORD
;
public
final
static
String
JMS_CONNECTION_FACTORY
=
CommonConstants
.
JMS_CONNECTION_FACTORY
;
public
final
static
String
JMS_QUEUE
=
CommonConstants
.
JMS_QUEUE
;
private
QueueConnectionFactory
qconFactory
;
private
QueueConnection
qcon
;
private
QueueSession
qsession
;
private
QueueSender
qsender
;
private
Queue
queue
;
private
TextMessage
message
;
private
UserInfoBean
userInfo
;
public
JMSSender
(
UserInfoBean
userInfo
)
{
try
{
this
.
userInfo
=
userInfo
;
init
();
JMSLogger
.
log
(
"3"
,
userInfo
,
null
,
"JMS Ready To Send Messages"
);
}
catch
(
Exception
e
)
{
JMSLogger
.
log
(
"3"
,
userInfo
,
null
,
"In JMSSender Exception:[ "
+
E12GenericUtility
.
getStackTrace
(
e
)
+
"]"
);
}
}
public
void
init
()
throws
NamingException
,
JMSException
{
JMSLogger
.
log
(
"3"
,
userInfo
,
null
,
"JMSSender.init()"
);
InitialContext
ctx
=
new
InitialContext
();
qconFactory
=
(
QueueConnectionFactory
)
ctx
.
lookup
(
JMS_CONNECTION_FACTORY
);
qcon
=
qconFactory
.
createQueueConnection
(
JMSSender
.
JMS_USERNAME
,
JMSSender
.
JMS_PASSWORD
);
qsession
=
qcon
.
createQueueSession
(
false
,
ActiveMQJMSConstants
.
INDIVIDUAL_ACKNOWLEDGE
);
queue
=
(
Queue
)
ctx
.
lookup
(
JMS_QUEUE
);
qsender
=
qsession
.
createSender
(
queue
);
message
=
qsession
.
createTextMessage
();
qcon
.
start
();
}
public
void
send
(
String
jmsData
)
throws
JMSException
{
// Added by Rahul P. on 26-Dec-23 to add Log in JMS_LOGS table -- [START]
String
sendStatus
=
"S"
;
E12GenericUtility
genericUtility
=
new
E12GenericUtility
();
String
msgType
=
message
.
getJMSType
();
JMSLogger
.
log
(
"3"
,
userInfo
,
null
,
"In JMSSender.send() => msgType : ["
+
msgType
+
"] => calling jmsLog().."
);
try
{
genericUtility
.
jmsLog
(
jmsData
,
sendStatus
,
""
,
msgType
);
// changed by Rahul P. on [16-Jan-24] for WORKFLOW and UPDATE_DIRTY_DATAMODEL msgType
}
catch
(
Exception
e
)
{
JMSLogger
.
log
(
"3"
,
userInfo
,
null
,
"In JMSSender.send() => Exception in catch block :[ "
+
E12GenericUtility
.
getStackTrace
(
e
)
+
"]"
);
}
// Added by Rahul P. on 26-Dec-23 to add Log in JMS_LOGS table -- [END]
try
{
JMSLogger
.
log
(
"3"
,
userInfo
,
null
,
"JMSSender.send() jmsData:["
+
jmsData
+
"]"
);
message
.
setText
(
jmsData
);
qsender
.
send
(
message
);
close
();
}
catch
(
Exception
e
)
{
// Added by Rahul P. on 26-Dec-23 to add Log in JMS_LOGS table -- [START]
sendStatus
=
"E"
;
try
{
genericUtility
.
jmsLog
(
jmsData
,
sendStatus
,
""
,
msgType
);
// changed by Rahul P. on [16-Jan-24] for WORKFLOW and UPDATE_DIRTY_DATAMODEL msgType
}
catch
(
Exception
e1
)
{
JMSLogger
.
log
(
"3"
,
userInfo
,
null
,
"In JMSSender.send() => Exception in catch block :[ "
+
E12GenericUtility
.
getStackTrace
(
e1
)
+
"]"
);
}
// Added by Rahul P. on 26-Dec-23 to add Log in JMS_LOGS table -- [END]
JMSLogger
.
log
(
"3"
,
userInfo
,
null
,
"In JMSSender.send() Exception:[ "
+
E12GenericUtility
.
getStackTrace
(
e
)
+
"]"
);
}
}
public
void
close
()
throws
JMSException
{
JMSLogger
.
log
(
"3"
,
userInfo
,
null
,
"JMSSender.close()"
);
qsender
.
close
();
qsession
.
close
();
qcon
.
close
();
}
public
TextMessage
getMessage
()
{
return
message
;
}
public
void
setMessage
(
TextMessage
message
)
{
this
.
message
=
message
;
}
public
QueueConnection
getConnection
()
{
return
qcon
;
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
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