Replace CRLF by LF
... because LF is now commonly used as newline code. Also some files in the samples directory has 755 permission but x bit is not needed. This removes the unnecessary bit as well. Change-Id: I6119e508481c9c0f8a5c1c2c40bb2e3a788abd3c
This commit is contained in:
parent
f246df12e5
commit
cdb55499f6
84
samples/java-api-for-websocket/receive_message/JsonDecoder.java
Executable file → Normal file
84
samples/java-api-for-websocket/receive_message/JsonDecoder.java
Executable file → Normal file
@ -1,43 +1,43 @@
|
|||||||
/*
|
/*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
||||||
* use this file except in compliance with the License. You may obtain a copy
|
* use this file except in compliance with the License. You may obtain a copy
|
||||||
* of the License at
|
* of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
* License for the specific language governing permissions and limitations under
|
* License for the specific language governing permissions and limitations under
|
||||||
* the License.
|
* the License.
|
||||||
*/
|
*/
|
||||||
package org.openstack.zaqar.sample;
|
package org.openstack.zaqar.sample;
|
||||||
|
|
||||||
import java.io.StringReader;
|
import java.io.StringReader;
|
||||||
|
|
||||||
import javax.json.Json;
|
import javax.json.Json;
|
||||||
import javax.json.JsonObject;
|
import javax.json.JsonObject;
|
||||||
import javax.websocket.Decoder;
|
import javax.websocket.Decoder;
|
||||||
import javax.websocket.EndpointConfig;
|
import javax.websocket.EndpointConfig;
|
||||||
|
|
||||||
public final class JsonDecoder implements Decoder.Text<JsonObject> {
|
public final class JsonDecoder implements Decoder.Text<JsonObject> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JsonObject decode(final String s) {
|
public JsonObject decode(final String s) {
|
||||||
return Json.createReader(new StringReader(s)).readObject();
|
return Json.createReader(new StringReader(s)).readObject();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void destroy() {
|
public void destroy() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void init(final EndpointConfig config) {
|
public void init(final EndpointConfig config) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean willDecode(final String s) {
|
public boolean willDecode(final String s) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
114
samples/java-api-for-websocket/receive_message/SampleZaqarEndpoint.java
Executable file → Normal file
114
samples/java-api-for-websocket/receive_message/SampleZaqarEndpoint.java
Executable file → Normal file
@ -1,57 +1,57 @@
|
|||||||
/*
|
/*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
||||||
* use this file except in compliance with the License. You may obtain a copy
|
* use this file except in compliance with the License. You may obtain a copy
|
||||||
* of the License at
|
* of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
* License for the specific language governing permissions and limitations under
|
* License for the specific language governing permissions and limitations under
|
||||||
* the License.
|
* the License.
|
||||||
*/
|
*/
|
||||||
import static java.lang.System.out;
|
import static java.lang.System.out;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
import javax.json.JsonObject;
|
import javax.json.JsonObject;
|
||||||
import javax.websocket.ClientEndpoint;
|
import javax.websocket.ClientEndpoint;
|
||||||
import javax.websocket.OnMessage;
|
import javax.websocket.OnMessage;
|
||||||
import javax.websocket.OnOpen;
|
import javax.websocket.OnOpen;
|
||||||
import javax.websocket.RemoteEndpoint;
|
import javax.websocket.RemoteEndpoint;
|
||||||
import javax.websocket.Session;
|
import javax.websocket.Session;
|
||||||
|
|
||||||
@ClientEndpoint(decoders = JsonDecoder.class)
|
@ClientEndpoint(decoders = JsonDecoder.class)
|
||||||
public final class SampleZaqarEndpoint {
|
public final class SampleZaqarEndpoint {
|
||||||
|
|
||||||
@OnMessage
|
@OnMessage
|
||||||
public void onMessage(final JsonObject msg) {
|
public void onMessage(final JsonObject msg) {
|
||||||
|
|
||||||
if (msg.getJsonObject("body").getJsonArray("messages") != null)
|
if (msg.getJsonObject("body").getJsonArray("messages") != null)
|
||||||
out.println(msg.getJsonObject("body").getJsonArray("messages")
|
out.println(msg.getJsonObject("body").getJsonArray("messages")
|
||||||
.getJsonObject(0).getString("body"));
|
.getJsonObject(0).getString("body"));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@OnOpen
|
@OnOpen
|
||||||
public void onOpen(final Session sess) throws IOException {
|
public void onOpen(final Session sess) throws IOException {
|
||||||
final RemoteEndpoint.Basic remote = sess.getBasicRemote();
|
final RemoteEndpoint.Basic remote = sess.getBasicRemote();
|
||||||
|
|
||||||
final String authenticateMsg = "{\"action\":\"authenticate\","
|
final String authenticateMsg = "{\"action\":\"authenticate\","
|
||||||
+ "\"headers\":{\"X-Auth-Token\":"
|
+ "\"headers\":{\"X-Auth-Token\":"
|
||||||
+ "\"8444886dd9b04a1b87ddb502b508261c\",\"X-Project-ID\":"
|
+ "\"8444886dd9b04a1b87ddb502b508261c\",\"X-Project-ID\":"
|
||||||
+ "\"7530fad032ca431e9dc8ed4a5de5d99c\"}}"; // refer to bug
|
+ "\"7530fad032ca431e9dc8ed4a5de5d99c\"}}"; // refer to bug
|
||||||
// #1553398
|
// #1553398
|
||||||
|
|
||||||
remote.sendText(authenticateMsg);
|
remote.sendText(authenticateMsg);
|
||||||
|
|
||||||
final String claimCreateMsg = "{\"action\":\"claim_create\",\"body\":"
|
final String claimCreateMsg = "{\"action\":\"claim_create\",\"body\":"
|
||||||
+ "{\"queue_name\":\"SampleQueue\"},\"headers\":{\"Client-ID\":"
|
+ "{\"queue_name\":\"SampleQueue\"},\"headers\":{\"Client-ID\":"
|
||||||
+ "\"355186cd-d1e8-4108-a3ac-a2183697232a\",\"X-Project-ID\":"
|
+ "\"355186cd-d1e8-4108-a3ac-a2183697232a\",\"X-Project-ID\":"
|
||||||
+ "\"7530fad032ca431e9dc8ed4a5de5d99c\"}}";
|
+ "\"7530fad032ca431e9dc8ed4a5de5d99c\"}}";
|
||||||
|
|
||||||
remote.sendText(claimCreateMsg);
|
remote.sendText(claimCreateMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
90
samples/java-api-for-websocket/send_message/SampleZaqarEndpoint.java
Executable file → Normal file
90
samples/java-api-for-websocket/send_message/SampleZaqarEndpoint.java
Executable file → Normal file
@ -1,45 +1,45 @@
|
|||||||
/*
|
/*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
||||||
* use this file except in compliance with the License. You may obtain a copy
|
* use this file except in compliance with the License. You may obtain a copy
|
||||||
* of the License at
|
* of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
* License for the specific language governing permissions and limitations under
|
* License for the specific language governing permissions and limitations under
|
||||||
* the License.
|
* the License.
|
||||||
*/
|
*/
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
import javax.websocket.ClientEndpoint;
|
import javax.websocket.ClientEndpoint;
|
||||||
import javax.websocket.OnOpen;
|
import javax.websocket.OnOpen;
|
||||||
import javax.websocket.RemoteEndpoint;
|
import javax.websocket.RemoteEndpoint;
|
||||||
import javax.websocket.Session;
|
import javax.websocket.Session;
|
||||||
|
|
||||||
@ClientEndpoint
|
@ClientEndpoint
|
||||||
public final class SampleZaqarEndpoint {
|
public final class SampleZaqarEndpoint {
|
||||||
|
|
||||||
@OnOpen
|
@OnOpen
|
||||||
public void onOpen(final Session sess) throws IOException {
|
public void onOpen(final Session sess) throws IOException {
|
||||||
final RemoteEndpoint.Basic remote = sess.getBasicRemote();
|
final RemoteEndpoint.Basic remote = sess.getBasicRemote();
|
||||||
|
|
||||||
final String authenticateMsg = "{\"action\":\"authenticate\","
|
final String authenticateMsg = "{\"action\":\"authenticate\","
|
||||||
+ "\"headers\":{\"X-Auth-Token\":"
|
+ "\"headers\":{\"X-Auth-Token\":"
|
||||||
+ "\"8444886dd9b04a1b87ddb502b508261c\",\"X-Project-ID\":"
|
+ "\"8444886dd9b04a1b87ddb502b508261c\",\"X-Project-ID\":"
|
||||||
+ "\"7530fad032ca431e9dc8ed4a5de5d99c\"}}"; // refer to bug
|
+ "\"7530fad032ca431e9dc8ed4a5de5d99c\"}}"; // refer to bug
|
||||||
// #1553398
|
// #1553398
|
||||||
|
|
||||||
remote.sendText(authenticateMsg);
|
remote.sendText(authenticateMsg);
|
||||||
|
|
||||||
final String messagePostMsg = "{\"action\":\"message_post\",\"body\":"
|
final String messagePostMsg = "{\"action\":\"message_post\",\"body\":"
|
||||||
+ "{\"messages\":[{\"body\":\"Zaqar Sample\"}],\"queue_name\":"
|
+ "{\"messages\":[{\"body\":\"Zaqar Sample\"}],\"queue_name\":"
|
||||||
+ "\"SampleQueue\"},\"headers\":{\"Client-ID\":"
|
+ "\"SampleQueue\"},\"headers\":{\"Client-ID\":"
|
||||||
+ "\"355186cd-d1e8-4108-a3ac-a2183697232a\",\"X-Project-ID\":"
|
+ "\"355186cd-d1e8-4108-a3ac-a2183697232a\",\"X-Project-ID\":"
|
||||||
+ "\"7530fad032ca431e9dc8ed4a5de5d99c\"}}";
|
+ "\"7530fad032ca431e9dc8ed4a5de5d99c\"}}";
|
||||||
|
|
||||||
remote.sendText(messagePostMsg);
|
remote.sendText(messagePostMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
64
samples/javascript/receive_message/zaqar_sample.js
Executable file → Normal file
64
samples/javascript/receive_message/zaqar_sample.js
Executable file → Normal file
@ -1,32 +1,32 @@
|
|||||||
/*
|
/*
|
||||||
* Licensed under the Apache License, Version 2.0 (the 'License'); you may not
|
* Licensed under the Apache License, Version 2.0 (the 'License'); you may not
|
||||||
* use this file except in compliance with the License. You may obtain a copy
|
* use this file except in compliance with the License. You may obtain a copy
|
||||||
* of the License at
|
* of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an 'AS IS' BASIS, WITHOUT
|
* distributed under the License is distributed on an 'AS IS' BASIS, WITHOUT
|
||||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
* License for the specific language governing permissions and limitations under
|
* License for the specific language governing permissions and limitations under
|
||||||
* the License.
|
* the License.
|
||||||
*/
|
*/
|
||||||
const ws = new WebSocket('ws://localhost:9000');
|
const ws = new WebSocket('ws://localhost:9000');
|
||||||
|
|
||||||
ws.onmessage = (e) => {
|
ws.onmessage = (e) => {
|
||||||
const msg = JSON.parse(e.data);
|
const msg = JSON.parse(e.data);
|
||||||
|
|
||||||
if (msg.body.messages)
|
if (msg.body.messages)
|
||||||
console.log(msg.body.messages[0].body);
|
console.log(msg.body.messages[0].body);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
ws.onopen = () => {
|
ws.onopen = () => {
|
||||||
ws.send('{"action": "authenticate", "headers": {"X-Auth-Token": \
|
ws.send('{"action": "authenticate", "headers": {"X-Auth-Token": \
|
||||||
"8444886dd9b04a1b87ddb502b508261c", "X-Project-ID": \
|
"8444886dd9b04a1b87ddb502b508261c", "X-Project-ID": \
|
||||||
"7530fad032ca431e9dc8ed4a5de5d99c"}}'); // refer to bug #1553398
|
"7530fad032ca431e9dc8ed4a5de5d99c"}}'); // refer to bug #1553398
|
||||||
|
|
||||||
ws.send('{"action": "claim_create", "body": {"queue_name": "SampleQueue"}, \
|
ws.send('{"action": "claim_create", "body": {"queue_name": "SampleQueue"}, \
|
||||||
"headers": {"Client-ID": "355186cd-d1e8-4108-a3ac-a2183697232a", \
|
"headers": {"Client-ID": "355186cd-d1e8-4108-a3ac-a2183697232a", \
|
||||||
"X-Project-ID": "7530fad032ca431e9dc8ed4a5de5d99c"}}');
|
"X-Project-ID": "7530fad032ca431e9dc8ed4a5de5d99c"}}');
|
||||||
};
|
};
|
||||||
|
50
samples/javascript/send_message/zaqar_sample.js
Executable file → Normal file
50
samples/javascript/send_message/zaqar_sample.js
Executable file → Normal file
@ -1,25 +1,25 @@
|
|||||||
/*
|
/*
|
||||||
* Licensed under the Apache License, Version 2.0 (the 'License'); you may not
|
* Licensed under the Apache License, Version 2.0 (the 'License'); you may not
|
||||||
* use this file except in compliance with the License. You may obtain a copy
|
* use this file except in compliance with the License. You may obtain a copy
|
||||||
* of the License at
|
* of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an 'AS IS' BASIS, WITHOUT
|
* distributed under the License is distributed on an 'AS IS' BASIS, WITHOUT
|
||||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
* License for the specific language governing permissions and limitations under
|
* License for the specific language governing permissions and limitations under
|
||||||
* the License.
|
* the License.
|
||||||
*/
|
*/
|
||||||
const ws = new WebSocket('ws://localhost:9000');
|
const ws = new WebSocket('ws://localhost:9000');
|
||||||
|
|
||||||
ws.onopen = () => {
|
ws.onopen = () => {
|
||||||
ws.send('{"action": "authenticate", "headers": {"X-Auth-Token": \
|
ws.send('{"action": "authenticate", "headers": {"X-Auth-Token": \
|
||||||
"8444886dd9b04a1b87ddb502b508261c", "X-Project-ID": \
|
"8444886dd9b04a1b87ddb502b508261c", "X-Project-ID": \
|
||||||
"7530fad032ca431e9dc8ed4a5de5d99c"}}'); // refer to bug #1553398
|
"7530fad032ca431e9dc8ed4a5de5d99c"}}'); // refer to bug #1553398
|
||||||
|
|
||||||
ws.send('{"action": "message_post", "body": {"messages": [{"body": \
|
ws.send('{"action": "message_post", "body": {"messages": [{"body": \
|
||||||
"Zaqar Sample"}], "queue_name": "SampleQueue"}, "headers": \
|
"Zaqar Sample"}], "queue_name": "SampleQueue"}, "headers": \
|
||||||
{"Client-ID": "355186cd-d1e8-4108-a3ac-a2183697232a", "X-Project-ID": \
|
{"Client-ID": "355186cd-d1e8-4108-a3ac-a2183697232a", "X-Project-ID": \
|
||||||
"7530fad032ca431e9dc8ed4a5de5d99c"}}');
|
"7530fad032ca431e9dc8ed4a5de5d99c"}}');
|
||||||
};
|
};
|
||||||
|
110
samples/jaxrs/receive_message/SampleZaqarServlet.java
Executable file → Normal file
110
samples/jaxrs/receive_message/SampleZaqarServlet.java
Executable file → Normal file
@ -1,55 +1,55 @@
|
|||||||
/*
|
/*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
||||||
* use this file except in compliance with the License. You may obtain a copy
|
* use this file except in compliance with the License. You may obtain a copy
|
||||||
* of the License at
|
* of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
* License for the specific language governing permissions and limitations under
|
* License for the specific language governing permissions and limitations under
|
||||||
* the License.
|
* the License.
|
||||||
*/
|
*/
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
import javax.servlet.annotation.WebServlet;
|
import javax.servlet.annotation.WebServlet;
|
||||||
import javax.servlet.http.HttpServlet;
|
import javax.servlet.http.HttpServlet;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
import javax.ws.rs.client.Client;
|
import javax.ws.rs.client.Client;
|
||||||
import javax.ws.rs.client.ClientBuilder;
|
import javax.ws.rs.client.ClientBuilder;
|
||||||
import javax.ws.rs.client.Entity;
|
import javax.ws.rs.client.Entity;
|
||||||
import javax.ws.rs.core.MultivaluedHashMap;
|
import javax.ws.rs.core.MultivaluedHashMap;
|
||||||
import javax.ws.rs.core.MultivaluedMap;
|
import javax.ws.rs.core.MultivaluedMap;
|
||||||
import javax.ws.rs.core.Response;
|
import javax.ws.rs.core.Response;
|
||||||
|
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
@WebServlet(name = "SampleServlet", value = "/")
|
@WebServlet(name = "SampleServlet", value = "/")
|
||||||
public final class SampleZaqarServlet extends HttpServlet {
|
public final class SampleZaqarServlet extends HttpServlet {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void doGet(final HttpServletRequest req,
|
protected void doGet(final HttpServletRequest req,
|
||||||
final HttpServletResponse resp) throws IOException {
|
final HttpServletResponse resp) throws IOException {
|
||||||
final Client client = ClientBuilder.newClient();
|
final Client client = ClientBuilder.newClient();
|
||||||
|
|
||||||
final MultivaluedMap<String, Object> headers =
|
final MultivaluedMap<String, Object> headers =
|
||||||
new MultivaluedHashMap<String, Object>();
|
new MultivaluedHashMap<String, Object>();
|
||||||
|
|
||||||
headers.putSingle("Client-ID", "355186cd-d1e8-4108-a3ac-a2183697232a");
|
headers.putSingle("Client-ID", "355186cd-d1e8-4108-a3ac-a2183697232a");
|
||||||
|
|
||||||
headers.putSingle("X-Auth-Token", "8444886dd9b04a1b87ddb502b508261c");
|
headers.putSingle("X-Auth-Token", "8444886dd9b04a1b87ddb502b508261c");
|
||||||
|
|
||||||
headers.putSingle("X-Project-Id", "7530fad032ca431e9dc8ed4a5de5d99c");
|
headers.putSingle("X-Project-Id", "7530fad032ca431e9dc8ed4a5de5d99c");
|
||||||
|
|
||||||
final Response res = client
|
final Response res = client
|
||||||
.target("http://localhost:8888/v2/queues/SampleQueue/claims")
|
.target("http://localhost:8888/v2/queues/SampleQueue/claims")
|
||||||
.request().headers(headers).post(Entity.json(""));
|
.request().headers(headers).post(Entity.json(""));
|
||||||
|
|
||||||
resp.getWriter().println(res.readEntity(String.class));
|
resp.getWriter().println(res.readEntity(String.class));
|
||||||
|
|
||||||
client.close();
|
client.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
104
samples/jaxrs/send_message/SampleZaqarServlet.java
Executable file → Normal file
104
samples/jaxrs/send_message/SampleZaqarServlet.java
Executable file → Normal file
@ -1,52 +1,52 @@
|
|||||||
/*
|
/*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
||||||
* use this file except in compliance with the License. You may obtain a copy
|
* use this file except in compliance with the License. You may obtain a copy
|
||||||
* of the License at
|
* of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
* License for the specific language governing permissions and limitations under
|
* License for the specific language governing permissions and limitations under
|
||||||
* the License.
|
* the License.
|
||||||
*/
|
*/
|
||||||
import javax.servlet.annotation.WebServlet;
|
import javax.servlet.annotation.WebServlet;
|
||||||
import javax.servlet.http.HttpServlet;
|
import javax.servlet.http.HttpServlet;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
import javax.ws.rs.client.Client;
|
import javax.ws.rs.client.Client;
|
||||||
import javax.ws.rs.client.ClientBuilder;
|
import javax.ws.rs.client.ClientBuilder;
|
||||||
import javax.ws.rs.client.Entity;
|
import javax.ws.rs.client.Entity;
|
||||||
import javax.ws.rs.core.MediaType;
|
import javax.ws.rs.core.MediaType;
|
||||||
import javax.ws.rs.core.MultivaluedHashMap;
|
import javax.ws.rs.core.MultivaluedHashMap;
|
||||||
import javax.ws.rs.core.MultivaluedMap;
|
import javax.ws.rs.core.MultivaluedMap;
|
||||||
|
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
@WebServlet(name = "SampleZaqarServlet", value = "/")
|
@WebServlet(name = "SampleZaqarServlet", value = "/")
|
||||||
public final class SampleZaqarServlet extends HttpServlet {
|
public final class SampleZaqarServlet extends HttpServlet {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void doGet(final HttpServletRequest req,
|
protected void doGet(final HttpServletRequest req,
|
||||||
final HttpServletResponse resp) {
|
final HttpServletResponse resp) {
|
||||||
final Client client = ClientBuilder.newClient();
|
final Client client = ClientBuilder.newClient();
|
||||||
|
|
||||||
final MultivaluedMap<String, Object> headers =
|
final MultivaluedMap<String, Object> headers =
|
||||||
new MultivaluedHashMap<String, Object>();
|
new MultivaluedHashMap<String, Object>();
|
||||||
|
|
||||||
headers.putSingle("Client-ID", "355186cd-d1e8-4108-a3ac-a2183697232a");
|
headers.putSingle("Client-ID", "355186cd-d1e8-4108-a3ac-a2183697232a");
|
||||||
|
|
||||||
headers.putSingle("X-Auth-Token", "8444886dd9b04a1b87ddb502b508261c");
|
headers.putSingle("X-Auth-Token", "8444886dd9b04a1b87ddb502b508261c");
|
||||||
|
|
||||||
headers.putSingle("X-Project-Id", "7530fad032ca431e9dc8ed4a5de5d99c");
|
headers.putSingle("X-Project-Id", "7530fad032ca431e9dc8ed4a5de5d99c");
|
||||||
|
|
||||||
client.target("http://localhost:8888/v2/queues/SampleQueue/messages")
|
client.target("http://localhost:8888/v2/queues/SampleQueue/messages")
|
||||||
.request(MediaType.APPLICATION_JSON_TYPE).headers(headers)
|
.request(MediaType.APPLICATION_JSON_TYPE).headers(headers)
|
||||||
.post(Entity
|
.post(Entity
|
||||||
.json("{\"messages\":[{\"body\":\"Zaqar Sample\"}]}"));
|
.json("{\"messages\":[{\"body\":\"Zaqar Sample\"}]}"));
|
||||||
|
|
||||||
client.close();
|
client.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
68
samples/nodejs/receive_message/zaqar_sample.js
Executable file → Normal file
68
samples/nodejs/receive_message/zaqar_sample.js
Executable file → Normal file
@ -1,34 +1,34 @@
|
|||||||
/*
|
/*
|
||||||
* Licensed under the Apache License, Version 2.0 (the 'License'); you may not
|
* Licensed under the Apache License, Version 2.0 (the 'License'); you may not
|
||||||
* use this file except in compliance with the License. You may obtain a copy
|
* use this file except in compliance with the License. You may obtain a copy
|
||||||
* of the License at
|
* of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an 'AS IS' BASIS, WITHOUT
|
* distributed under the License is distributed on an 'AS IS' BASIS, WITHOUT
|
||||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
* License for the specific language governing permissions and limitations under
|
* License for the specific language governing permissions and limitations under
|
||||||
* the License.
|
* the License.
|
||||||
*/
|
*/
|
||||||
const WebSocket = require('ws');
|
const WebSocket = require('ws');
|
||||||
|
|
||||||
const ws = new WebSocket('ws://localhost:9000');
|
const ws = new WebSocket('ws://localhost:9000');
|
||||||
|
|
||||||
ws.on('message', (data, flags) => {
|
ws.on('message', (data, flags) => {
|
||||||
const msg = JSON.parse(data);
|
const msg = JSON.parse(data);
|
||||||
|
|
||||||
if (msg.body.messages)
|
if (msg.body.messages)
|
||||||
console.log(msg.body.messages[0].body);
|
console.log(msg.body.messages[0].body);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
ws.on('open', () => {
|
ws.on('open', () => {
|
||||||
ws.send('{"action": "authenticate", "headers": {"X-Auth-Token": \
|
ws.send('{"action": "authenticate", "headers": {"X-Auth-Token": \
|
||||||
"8444886dd9b04a1b87ddb502b508261c", "X-Project-ID": \
|
"8444886dd9b04a1b87ddb502b508261c", "X-Project-ID": \
|
||||||
"7530fad032ca431e9dc8ed4a5de5d99c"}}'); // refer to bug #1553398
|
"7530fad032ca431e9dc8ed4a5de5d99c"}}'); // refer to bug #1553398
|
||||||
|
|
||||||
ws.send('{"action": "claim_create", "body": {"queue_name": "SampleQueue"}, \
|
ws.send('{"action": "claim_create", "body": {"queue_name": "SampleQueue"}, \
|
||||||
"headers": {"Client-ID": "355186cd-d1e8-4108-a3ac-a2183697232a", \
|
"headers": {"Client-ID": "355186cd-d1e8-4108-a3ac-a2183697232a", \
|
||||||
"X-Project-ID": "7530fad032ca431e9dc8ed4a5de5d99c"}}');
|
"X-Project-ID": "7530fad032ca431e9dc8ed4a5de5d99c"}}');
|
||||||
});
|
});
|
||||||
|
54
samples/nodejs/send_message/zaqar_sample.js
Executable file → Normal file
54
samples/nodejs/send_message/zaqar_sample.js
Executable file → Normal file
@ -1,27 +1,27 @@
|
|||||||
/*
|
/*
|
||||||
* Licensed under the Apache License, Version 2.0 (the 'License'); you may not
|
* Licensed under the Apache License, Version 2.0 (the 'License'); you may not
|
||||||
* use this file except in compliance with the License. You may obtain a copy
|
* use this file except in compliance with the License. You may obtain a copy
|
||||||
* of the License at
|
* of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an 'AS IS' BASIS, WITHOUT
|
* distributed under the License is distributed on an 'AS IS' BASIS, WITHOUT
|
||||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
* License for the specific language governing permissions and limitations under
|
* License for the specific language governing permissions and limitations under
|
||||||
* the License.
|
* the License.
|
||||||
*/
|
*/
|
||||||
const WebSocket = require('ws');
|
const WebSocket = require('ws');
|
||||||
|
|
||||||
const ws = new WebSocket('ws://localhost:9000');
|
const ws = new WebSocket('ws://localhost:9000');
|
||||||
|
|
||||||
ws.on('open', () => {
|
ws.on('open', () => {
|
||||||
ws.send('{"action": "authenticate", "headers": {"X-Auth-Token": \
|
ws.send('{"action": "authenticate", "headers": {"X-Auth-Token": \
|
||||||
"8444886dd9b04a1b87ddb502b508261c", "X-Project-ID": \
|
"8444886dd9b04a1b87ddb502b508261c", "X-Project-ID": \
|
||||||
"7530fad032ca431e9dc8ed4a5de5d99c"}}'); // refer to bug #1553398
|
"7530fad032ca431e9dc8ed4a5de5d99c"}}'); // refer to bug #1553398
|
||||||
|
|
||||||
ws.send('{"action": "message_post", "body": {"messages": [{"body": \
|
ws.send('{"action": "message_post", "body": {"messages": [{"body": \
|
||||||
"Zaqar Sample"}], "queue_name": "SampleQueue"}, "headers": \
|
"Zaqar Sample"}], "queue_name": "SampleQueue"}, "headers": \
|
||||||
{"Client-ID": "355186cd-d1e8-4108-a3ac-a2183697232a", "X-Project-ID": \
|
{"Client-ID": "355186cd-d1e8-4108-a3ac-a2183697232a", "X-Project-ID": \
|
||||||
"7530fad032ca431e9dc8ed4a5de5d99c"}}');
|
"7530fad032ca431e9dc8ed4a5de5d99c"}}');
|
||||||
});
|
});
|
||||||
|
0
samples/python-zaqarclient/receive_message/zaqar_sample.py
Executable file → Normal file
0
samples/python-zaqarclient/receive_message/zaqar_sample.py
Executable file → Normal file
0
samples/python-zaqarclient/send_message/zaqar_sample.py
Executable file → Normal file
0
samples/python-zaqarclient/send_message/zaqar_sample.py
Executable file → Normal file
Loading…
Reference in New Issue
Block a user