Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
joram
joram
Commits
f63f81f9
Commit
f63f81f9
authored
Oct 04, 2017
by
afreyssin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Receive code from helper.
parent
1d11ab94
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
1 deletion
+32
-1
joram/joram/tools/rest/jms/src/main/java/org/objectweb/joram/tools/rest/jms/ConsumerContext.java
...a/org/objectweb/joram/tools/rest/jms/ConsumerContext.java
+32
-1
No files found.
joram/joram/tools/rest/jms/src/main/java/org/objectweb/joram/tools/rest/jms/ConsumerContext.java
View file @
f63f81f9
...
@@ -26,6 +26,7 @@ import java.util.Map.Entry;
...
@@ -26,6 +26,7 @@ import java.util.Map.Entry;
import
java.util.concurrent.ConcurrentHashMap
;
import
java.util.concurrent.ConcurrentHashMap
;
import
javax.jms.JMSConsumer
;
import
javax.jms.JMSConsumer
;
import
javax.jms.JMSContext
;
import
javax.jms.JMSException
;
import
javax.jms.JMSException
;
import
javax.jms.Message
;
import
javax.jms.Message
;
...
@@ -65,7 +66,7 @@ public class ConsumerContext extends SessionContext {
...
@@ -65,7 +66,7 @@ public class ConsumerContext extends SessionContext {
return
-
1
;
return
-
1
;
}
}
p
ublic
void
put
(
long
id
,
Message
msg
)
{
p
rivate
final
void
put
(
long
id
,
Message
msg
)
{
if
(
msg
==
null
)
if
(
msg
==
null
)
return
;
return
;
if
(
id
>
getLastId
())
if
(
id
>
getLastId
())
...
@@ -74,9 +75,39 @@ public class ConsumerContext extends SessionContext {
...
@@ -74,9 +75,39 @@ public class ConsumerContext extends SessionContext {
}
}
public
Message
getMessage
(
long
id
)
{
public
Message
getMessage
(
long
id
)
{
getClientCtx
().
setLastActivity
(
System
.
currentTimeMillis
());
return
messages
.
get
(
id
);
return
messages
.
get
(
id
);
}
}
synchronized
Message
receive
(
long
timeout
,
long
msgId
)
throws
JMSException
{
Message
message
=
null
;
if
(
timeout
>
0
)
message
=
getConsumer
().
receive
(
timeout
);
else
if
(
timeout
==
0
)
message
=
getConsumer
().
receiveNoWait
();
else
{
message
=
getConsumer
().
receive
();
if
(
message
==
null
)
throw
new
JMSException
(
"The consumer expire (timeout)"
);
}
//update activity
getClientCtx
().
setLastActivity
(
System
.
currentTimeMillis
());
if
(
message
!=
null
)
{
if
(
getJmsContext
().
getSessionMode
()
==
JMSContext
.
CLIENT_ACKNOWLEDGE
)
{
long
id
=
msgId
;
if
(
id
==
-
1
)
id
=
incLastId
();
put
(
id
,
message
);
}
else
{
incLastId
();
}
}
return
message
;
}
public
Message
removeMessage
(
long
id
)
{
public
Message
removeMessage
(
long
id
)
{
return
messages
.
remove
(
id
);
return
messages
.
remove
(
id
);
}
}
...
...
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