Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

AMQP webhook #159

Merged
merged 1 commit into from
Mar 15, 2017
Merged

AMQP webhook #159

merged 1 commit into from
Mar 15, 2017

Conversation

m1ome
Copy link
Contributor

@m1ome m1ome commented Mar 13, 2017

Agenda
Issue: #157
Support: 0.9.1 AMQP protocol (RabbitMQ)

Libraries
AMQP: streadway/amqp

Prerequisites

  1. RabbitMQ
  2. RabbitMQ Management tool

Work logic

  1. Connect to RabbitMQ
  2. Create Exchange named <EXCHANGE_NAME>
  3. Create Queue named <EXCHANGE_NAME>
  4. Create RouteKey<ROUTE_KEY:[tile38]> binded from Exchange <EXCHANGE_NAME> to Queue <EXCHANGE_NAME>
  5. Publish into Queue <EXCHANGE_NAME> with RouteKey<ROUTE_KEY:[tile38]>

Usage

SETHOOK amqp amqp://guest:guest@127.0.0.1: 5672/tile38?route=tile NEARBY fleet FENCE POINT 30 30 500

Message
Content-Type is application/json

{"command":"set","group":"58c6ba02778404601d4927d1","detect":"inside","hook":"amqp","key":"fleet","time":"2017-03-13T18:28:22.628925432+03:00","id":"truck1","object":{"type":"Point","coordinates":[30,30]}}

route - is optional parameter, by default it equals to tile38

Defaults
type - 'direct'
durable - true
immediate - false
mandatory - false
auto_delete - false
internal - false
no_wait - false
delivery_mode - 1
route - tile38

@tidwall wanna your thoughts about it.

@m1ome m1ome mentioned this pull request Mar 14, 2017
@paavalan
Copy link

@m1ome everything looks good, thanks

@tidwall
Copy link
Owner

tidwall commented Mar 14, 2017

@m1ome I hope to get to testing and merging soon. Thanks for your patience.

@m1ome
Copy link
Contributor Author

m1ome commented Mar 14, 2017

@tidwall don't worry all is fine 👍

@tidwall
Copy link
Owner

tidwall commented Mar 15, 2017

On Mac installed RabbitMQ

$ brew install rabbitmq

Started the server

$ /usr/local/sbin/rabbitmq-server

Added the simple hook

TILE38> SETHOOK amqp amqp://guest:guest@localhost:5672/tile38 NEARBY fleet FENCE POINT 30 30 500

Added a point

TILE38> ADD fleet asdf POINT 30 30

Then read the message off of the RabbitMQ queue

$ rabbitmqadmin get queue=tile38 requeue=false
+-------------+----------+---------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+---------------+------------------+-------------+
| routing_key | exchange | message_count |                                                                                                   payload                                                                                                    | payload_bytes | payload_encoding | redelivered |
+-------------+----------+---------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+---------------+------------------+-------------+
| tile38      | tile38   | 0             | {"command":"set","group":"58c97adcd5eefdab69f686a3","detect":"outside","hook":"amqp","key":"fleet","time":"2017-03-15T10:35:14.408150365-07:00","id":"asdf","object":{"type":"Point","coordinates":[31,30]}} | 204           | string           | False       |
+-------------+----------+---------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+---------------+------------------+-------------+

I think this is a good start. I'm merging shortly.

@tidwall tidwall merged commit 710ed96 into tidwall:master Mar 15, 2017
@paavalan
Copy link

@m1ome @tidwall thanks. sounds good.

@Lars-Meijer
Copy link

When connecting goes wrong there is no way to get feedback, is this intended behavior and is this also the case for other connectors like Kafka?

@m1ome
Copy link
Contributor Author

m1ome commented Mar 17, 2017

@Lars-Meijer you can use -vv to make sure all stuff connected correctly

@Lars-Meijer
Copy link

Thanks will test that sometime later 👍

@tidwall
Copy link
Owner

tidwall commented Mar 17, 2017

@Lars-Meijer Yes it's intended behavior for hooks to silently fail, as far as the client is concerned. Though logging failures on the server side without -vv would be useful.

@m1ome
Copy link
Contributor Author

m1ome commented Mar 17, 2017

@tidwall I can do this portion of logging, just make an issue and set this to me.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants