-
Notifications
You must be signed in to change notification settings - Fork 2
/
local_ems.rs
98 lines (86 loc) · 2.99 KB
/
local_ems.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#[cfg(test)]
#[cfg(feature = "test_with_ems")]
mod local_ems {
use std::collections::HashMap;
use tibco_ems::Destination;
use tibco_ems::Message;
use tibco_ems::TextMessage;
use tibco_ems::TypedValue;
#[test]
fn test_correlation_id_setter() {
let url = "tcp://localhost:7222";
let user = "admin";
let password = "admin";
let connection = tibco_ems::connect(url, user, password).unwrap();
let session = connection.session().unwrap();
let mut header = HashMap::new();
header.insert(
"CorrelationID".to_string(),
TypedValue::String("VALUE_1".to_string()),
);
let msg = TextMessage {
body: "hallo welt".to_string(),
header: Some(header),
..Default::default()
};
let destination = Destination::Queue("myqueue".to_string());
let _ignore = session.send_message(&destination, msg);
let consumer = session.queue_consumer(&destination, None).unwrap();
let msg_result = consumer.receive_message(Some(10000));
match msg_result {
Ok(res) => match res {
Some(response_msg) => match &response_msg {
Message::TextMessage(txt_msg) => {
println!("got message: {:?}", txt_msg);
}
_ => {
panic!("expected text message");
}
},
None => {
panic!("no message received");
}
},
Err(e) => {
println!("{:?}", e);
}
}
}
#[test]
fn test_correlation_id_none() {
env_logger::init();
let url = "tcp://localhost:7222";
let user = "admin";
let password = "admin";
let connection = tibco_ems::connect(url, user, password).unwrap();
let session = connection.session().unwrap();
let mut header = HashMap::new();
let msg = TextMessage {
body: "hallo welt".to_string(),
header: Some(header),
..Default::default()
};
let destination = Destination::Queue("myqueue".to_string());
let _ignore = session.send_message(&destination, msg);
let consumer = session.queue_consumer(&destination, None).unwrap();
let msg_result = consumer.receive_message(Some(10000));
match msg_result {
Ok(res) => match res {
Some(response_msg) => match &response_msg {
Message::TextMessage(txt_msg) => {
println!("got message: {:?}", txt_msg);
}
_ => {
panic!("expected text message");
}
},
None => {
panic!("no message received");
}
},
Err(e) => {
println!("{:?}", e);
}
}
}
}