FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
rabbitmq-tutorials/java/ReceiveLogs.java at main · rabbitmq/rabbitmq-tutorials · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
rabbitmq
/
rabbitmq-tutorials
Public
Notifications
You must be signed in to change notification settings
Fork
3.5k
Star
6.9k
Code
Issues
3
Pull requests
1
Discussions
Actions
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Discussions
Actions
Security and quality
Insights
Expand file tree
Breadcrumbs
rabbitmq-tutorials
/
java
/
ReceiveLogs.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
25 lines (19 loc) · 976 Bytes
Breadcrumbs
rabbitmq-tutorials
/
java
/
ReceiveLogs.java
Copy path
File metadata and controls
25 lines (19 loc) · 976 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import
com
.
rabbitmq
.
client
.*;
public
class
ReceiveLogs
{
private
static
final
String
EXCHANGE_NAME
=
"logs"
;
public
static
void
main
(
String
[]
argv
)
throws
Exception
{
ConnectionFactory
factory
=
new
ConnectionFactory
();
factory
.
setHost
(
"localhost"
);
Connection
connection
=
factory
.
newConnection
();
Channel
channel
=
connection
.
createChannel
();
channel
.
exchangeDeclare
(
EXCHANGE_NAME
,
BuiltinExchangeType
.
FANOUT
);
String
queueName
=
channel
.
queueDeclare
().
getQueue
();
channel
.
queueBind
(
queueName
,
EXCHANGE_NAME
,
""
);
System
.
out
.
println
(
" [*] Waiting for messages. To exit press CTRL+C"
);
DeliverCallback
deliverCallback
= (
consumerTag
,
delivery
) -> {
String
message
=
new
String
(
delivery
.
getBody
(),
"UTF-8"
);
System
.
out
.
println
(
" [x] Received '"
+
message
+
"'"
);
};
channel
.
basicConsume
(
queueName
,
true
,
deliverCallback
,
consumerTag
-> { });
}
}
Back
|
FazBrowse Home
|
New Git URL