I am trying to write a client server application that communicate using Message Objects(Message Class is defined in my application). there is a scenario in which i want to transfer file between them. First I must send a message to client to notify it about specific file information and after that the file itself is going to be written to channel.
The problem is how can I handle this scenario in client?
Is it a good solution to remove Message handler after receiving message and replace it with a byte array handler?
what are the alternatives?
Sure you can just modify the pipeline on the fly. We do something similar in our portunification example[1].
[1] https://github.com/netty/netty/blob/4.0/example/src/main/java/io/netty/example/portunification/PortUnificationServerHandler.java
Related
In SLACK, Is it possible to create commands for an app which post messages to different channels?
This is what I am trying to achieve:
I run a Slash command from my DM which will post a message in a channel, which I am not a part of.
A member of that channel now runs another command to reply me and his response should be received by me either in my app’s messages or in the same channel but visible to me only.
Can this be achieved ?
A bot token, (xoxb) can send messages to any public channel using the chat.postMessage method and the [chat:write/public][1] scope. For that, the bot does not need to be a member of the channel. The bot can also send 1:1 DMs to users if you pass their user id as the channel parameter in a call to chat.postMessage but the bot won't be able to post into a private channel or multi-person DM it is not a member of. To send messages in-channel that can only be viewed by a specific user, check out [chat.postEphemeral][1], the user seeing this message must be a member of the channel.
What you mentioned in the question can be achieved using Slack's 'Interactivity' features. (Slash Commands & App Shortcuts)
You'll need to implement code to capture 'command', and then use Slack's WebAPIs to achieve the result.
(Chat APIs)
I have an application using MQTT implemented with the paho-mqtt-1.0.2 and I am using ActiveMQ as the broker. I have a class implementing the MqttCallback, what I am wondering is why does the client hang
#Override
messageArrived(...)
do work
mqtt.publish(TOPIC,PAYLOAD,2,false) <- here
I want to send a "response" message to the broker for the next step of the work to be done. Similar to this, I read in the docs for that callback function
It is possible to send a new message within an implementation of this callback (for example, a response to this message), but the implementation must not disconnect the client, as it will be impossible to send an acknowledgment for the message being processed, and a deadlock will occur.
Has anyone out there tried doing the above and get it to work?
I also tried using the MqttAsyncClient and that ended up with
"Error too many publishes in progress" leading to undelivered messages.
I know how to get around this issue, I'm not looking for workaround; I'm looking for receiving and publishing on the thread where messageArrived() gets executed.
Happy Hunting!
How I can send file from one client (A) to another one (B) via socket? and vice versa, send file from B to A. I mean that make the client sender and receiver at the same time.
In other word, when muticlient connect to server, how I distinguish between clients ?
You need to implement you own communication message format in short a simple protocol .
You keep a list of all active sockets in a shared list/map , and based on the request from the message you pick up the apt client and push the desired message to that.
You can implement the actual message format as you want, but this can be the blueprint.
In this case lets say your client A sends message : 1. Client Id 2. File Start 3 X . File Content 4. File End
as soon as you get a connection you get the target client id , the file start message lets you understand the next message just needs to be diverted to target and file End message defines the transfer complete.
Also, you may would like to send Acknowledgement message from server to client, in order to eradicate transfer issues.
It is good way to manage client using their id(i.e. a unique long or string or any other for each user). At the time of connection to socket client send their id , store that is in collection. And when a user(Client) want to send file send with own id and Id of that user(Client) want to send.
We are using Camel fluent builders to set up a series of complex routes, in which we are using dynamic routing using the RecipientList functionality.
We've encountered issues where in some cases, the recipient list contains a messaging endpoint that doesn't exist (for example, something like seda:notThere).
A simple example is something like this:
from("seda:SomeSource")....to("seda:notThere");
How can I configure the route so that if the exchange tries to route to an endpoint that doesn't already exist, an error is thrown?
I'm using Camel 2.9.x, and I've already experimented with the Dead Letter Channel and various Error Handler implementations, with (seemingly) no errors or warnings logged.
The only logging I see indicates that Camel is (attempting to) send to the endpoint which doesn't exist:
2013-07-03 16:07:08,030|main|DEBUG|o.a.c.p.SendProcessor|>>>> Endpoint[seda://notThere] Exchange[Message: x.y.Z#293b9fae]
Thanks in advance!
All endpoints behave differently in this case.
If you attempt to write to a ftp server that does not exist, you certainly get an error (connection refused or otherwise)..
This is also true for a number of endpoints.
SEDA queues gets created if the do not exist and the message will be left there. So your route actually sends to "notThere" and the message will still be there until the application restarts or someone starts to consume messages from seda:notThere. This is the way seda queues are designed. If you set the size of the seda queue by to("seda:notThere?size=100"), then if there is noone reading (or reading slowly) you will get exceptions on message 101 and forward.
If you need to be sure some route is consuming your messages, use "direct" instead of "seda". You can even have some middle layer to use the features of seda with respect to staging and the features of direct knowing there is a consumer active (if sent from recipient list with perhaps user input (god forbid).
from("whatever").recipentList( ... ); // "direct:ep1" work, "direct:ep2" throws exception
from("direct:ep1").to("seda:ep1");
from("seda:ep1").doRealStagedStuffHere();
I'm struggling with one thing in Storm.
So the whole idea is:
Send a request to the storm (probably to DRPC Server). The request will tell Storm what is the source of streams. For example: Image that I have two files 1 - '/var/log/syslog' and 2- ' /var/log/udev' . I want to be able to send the request to the "Storm" to tell it what file to process.
What I don't understand:
When I said send request to the "Storm", - Where should I send it? ( I assume that DRPC server controls what source needs to be send to topology. But how to implement DRPC server? Is there some class like DRPCServer server = new DRPCServer()? And how to tell Spout to look at the DRPCServer?Or is the request needs to be send directly to the Spout? if So how to make it start using specified source? I mean do I need to send request to the open() method?
Not DRPCServer, its DRPCClient
DRPCClient client = new DRPCClient("drpc-host", 3772);
I think you will be really interested after seeing this
UPDATE:
And for more information you can always check the storm-starter project in github by nathanmarz and especially BasicDRPCTopologyand ReachTopology