Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
joram
joram
Commits
bc617eab
Commit
bc617eab
authored
Jan 15, 2021
by
Andre Freyssinet
Browse files
Adds a constructor with ConnectionFactory as parameter.
parent
eaf58e42
Changes
1
Hide whitespace changes
Inline
Side-by-side
joram/joram/tools/jmscheck/src/main/java/org/ow2/joram/tools/jmscheck/JMSConnectorCheck.java
View file @
bc617eab
...
...
@@ -198,16 +198,51 @@ public final class JMSConnectorCheck {
String
user
,
String
pass
,
String
qname
,
int
timeOut
)
{
if
(
cfname
==
null
)
throw
new
IllegalArgumentException
(
"Shall define ConnectionFactory name"
);
this
.
cfname
=
cfname
;
if
(
ictx
==
null
)
throw
new
IllegalArgumentException
(
"Shall define JNDI initial context"
);
this
.
ictx
=
ictx
;
this
.
user
=
user
;
this
.
pass
=
pass
;
if
(
qname
==
null
)
throw
new
IllegalArgumentException
(
"Shall define Queue name"
);
this
.
qname
=
qname
;
this
.
timeout
=
timeOut
;
}
/**
* Creates a new component allowing to check a JMS connector.
*
* @param cf ConnectionFactory to use.
* @param user User name for authentication, if no defined uses the ConnectionFactory default.
* @param pass Password for authentication, if no defined uses the ConnectionFactory default.
* @param qname Internal name of JMS destination.
* @param timeout Maximum amount of time to wait connecting and receiving messages, by default 10s.
*/
public
JMSConnectorCheck
(
ConnectionFactory
cf
,
String
user
,
String
pass
,
String
qname
,
int
timeOut
)
{
if
(
cf
==
null
)
throw
new
IllegalArgumentException
(
"Shall define ConnectionFactory"
);
this
.
cf
=
cf
;
this
.
user
=
user
;
this
.
pass
=
pass
;
if
(
qname
==
null
)
throw
new
IllegalArgumentException
(
"Shall define Queue name"
);
this
.
timeout
=
timeOut
;
}
private
void
getConnectionFactory
()
throws
NamingException
{
if
(
cf
!=
null
)
return
;
...
...
@@ -239,7 +274,7 @@ public final class JMSConnectorCheck {
*/
public
boolean
check
()
{
if
(
logger
.
isLoggable
(
BasicLevel
.
DEBUG
))
logger
.
log
(
BasicLevel
.
DEBUG
,
"JMSConnectorStatus("
+
cfname
+
").check"
);
logger
.
log
(
BasicLevel
.
DEBUG
,
"JMSConnectorStatus("
+
((
cfname
==
null
)?
""
:
cfname
)
+
").check"
);
nbtry
+=
1
;
try
{
...
...
@@ -251,9 +286,9 @@ public final class JMSConnectorCheck {
setLatencyPubSub
(-
1L
);
errorMsg
=
"Cannot get ConnectionFactory"
;
if
(
logger
.
isLoggable
(
BasicLevel
.
DEBUG
))
logger
.
log
(
BasicLevel
.
WARN
,
"JMSConnectorStatus.check("
+
cfname
+
")<: Cannot get ConnectionFactory."
,
exc
);
logger
.
log
(
BasicLevel
.
WARN
,
"JMSConnectorStatus.check("
+
((
cfname
==
null
)?
""
:
cfname
)
+
")<: Cannot get ConnectionFactory."
,
exc
);
else
logger
.
log
(
BasicLevel
.
WARN
,
"JMSConnectorStatus.check("
+
cfname
+
"): Cannot get ConnectionFactory."
);
logger
.
log
(
BasicLevel
.
WARN
,
"JMSConnectorStatus.check("
+
((
cfname
==
null
)?
""
:
cfname
)
+
"): Cannot get ConnectionFactory."
);
return
false
;
}
...
...
@@ -274,9 +309,9 @@ public final class JMSConnectorCheck {
setLatencyPubSub
(-
1L
);
errorMsg
=
"Cannot connect"
;
if
(
logger
.
isLoggable
(
BasicLevel
.
DEBUG
))
logger
.
log
(
BasicLevel
.
WARN
,
"JMSConnectorStatus.check("
+
cfname
+
"): Cannot connect."
,
exc
);
logger
.
log
(
BasicLevel
.
WARN
,
"JMSConnectorStatus.check("
+
((
cfname
==
null
)?
""
:
cfname
)
+
"): Cannot connect."
,
exc
);
else
logger
.
log
(
BasicLevel
.
WARN
,
"JMSConnectorStatus.check("
+
cfname
+
"): Cannot connect."
);
logger
.
log
(
BasicLevel
.
WARN
,
"JMSConnectorStatus.check("
+
((
cfname
==
null
)?
""
:
cfname
)
+
"): Cannot connect."
);
return
false
;
}
...
...
@@ -312,18 +347,18 @@ public final class JMSConnectorCheck {
setLatencyPubSub
(-
1L
);
errorMsg
=
"Error during message send/receive."
;
if
(
logger
.
isLoggable
(
BasicLevel
.
DEBUG
))
logger
.
log
(
BasicLevel
.
WARN
,
"JMSConnectorStatus.check("
+
cfname
+
"): Error during message send/receive."
,
exc
);
logger
.
log
(
BasicLevel
.
WARN
,
"JMSConnectorStatus.check("
+
((
cfname
==
null
)?
""
:
cfname
)
+
"): Error during message send/receive."
,
exc
);
else
logger
.
log
(
BasicLevel
.
WARN
,
"JMSConnectorStatus.check("
+
cfname
+
"): Error during message send/receive."
);
logger
.
log
(
BasicLevel
.
WARN
,
"JMSConnectorStatus.check("
+
((
cfname
==
null
)?
""
:
cfname
)
+
"): Error during message send/receive."
);
return
false
;
}
finally
{
try
{
cnx
.
close
();
}
catch
(
JMSException
exc
)
{
if
(
logger
.
isLoggable
(
BasicLevel
.
DEBUG
))
logger
.
log
(
BasicLevel
.
WARN
,
"JMSConnectorStatus.check("
+
cfname
+
"): Error closing connection."
,
exc
);
logger
.
log
(
BasicLevel
.
WARN
,
"JMSConnectorStatus.check("
+
((
cfname
==
null
)?
""
:
cfname
)
+
"): Error closing connection."
,
exc
);
else
logger
.
log
(
BasicLevel
.
WARN
,
"JMSConnectorStatus.check("
+
cfname
+
"): Error closing connection."
);
logger
.
log
(
BasicLevel
.
WARN
,
"JMSConnectorStatus.check("
+
((
cfname
==
null
)?
""
:
cfname
)
+
"): Error closing connection."
);
}
}
}
...
...
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