Open anshulupreti opened 3 years ago
Hi, so you need to activate the cronjob system s. https://fusio.readthedocs.io/en/latest/concept/cronjob.html which then enables Fusio to execute all events at the background. Regarding your post call, you need to provide an Bearer
token at the authorization header which you can obtain at the /consumer/login
endpoint s.
https://demo.fusio-project.org/apps/internal/#!/api/consumer/login
Thank you so much! I was successfully able to subscribe and get the response as Subscription created successfully.
However, the subscriber dispatch event's does not send back the data to the listener like in your example with "foo" => "bar"
I just get the subscription successfully created response and that's all. Even though the CRON is running through the backend app and everything seems to be mapped properly. Any idea why?
Hi Chris,
Please let me know what to do here?
Hi, mhhh could you check whether the table fusio_event_trigger
contains an entry containing the payload which you want to send via the event.
Yes it does. here is the format: {"specversion":"1.0","type":"org.fusio-project.event.create","source":"\/backend\/event\/subscription","id":"86f029dc-a025-47d9-9991-12db839c57f3","datacontenttype":"application\/json","data":{"id":15,"eventId":43,"userId":4,"endpoint":"https:\/\/xxxxxxxx.in\/fusio\/public\/index.php\/order_call"}}
Please suggest what can be done. If you have some support channel on paid basis, I can use that too.
ok, to debug this further let us first check whether I have understood your setup currectly. So you have created an custom event "subscribe_v1". Then you have an action, which gets invoked via the route /order_call
which dispatches data to this event via:
$this->dispatcher->dispatch('subscribe_v1', [
'foo' => 'bar'
]);
Then you have created a subscription for this event. If you now invoke the action which dispatches the data, all subscribed endpoints should be notified. So the data which you haved posted was from the internal event but there should be an event containing the {"foo": "bar"}
data, this is the data which you have provided at the action.
Iam wondering why the subscribe event contains the "/order_call" route in general this should be a different url where you want to post this data. Otherwise you basically dispatch an event to the same url which has triggered the event. To test the callback you could subscribe to the event via a service like https://httpbin.org/ where you can see the HTTP request.
So in general the Fusio pub/sub system should be used to handle webhooks i.e. if your app triggers an event all subscribed urls can be notified via a webhook. It is not directly a system to handle push notifications for a frontend app. But this would be indeed a nice addition to Fusio if we could help to simplify this use case,
Hi Chris, thanks. Yes I think you got it right.
I will help you in understanding this better. by telling you my use case.
P is used to save the local copy of the data sent to B and to provide endpoints to receive the response or updated information. This part works absolutely fine.
B also sends real time notifictions/calls whenever an external action is generated. And since B can send multiple requests any hour/section or minute, A needs to keep subscribed to P and wait for a state change or data stack whenever a new event notification is sent from B to P. Since A is a front end app (angular) it cannot have its own endpoints and relying on Fusio to mediate the data transaction between B to A.
This is what is happening right now or needs to happen:
This is the outline of what needs to happen with the real time ordering section. I hope you haunder stpod. of amy questions, pleqe tell.accpreciate
Hi Chris,
Any comments on this?
I am unable to figure out how to get the pub/sub setup.
I have created a route for the event to be executed in real time and send out the push notification to the frontend application but this doesnt seem to be working. Following are the details of what I have done vs what I am trying to accompolish
Routes.php
/order_call: This will be the endpoint to which the frontend app will subscribe to. This route is set to resolve to a php file that pulls out the data.
subscription.php: This will be the file pulling the data. This file has the dispatcher event in the format:
$this->dispatcher->dispatch('subscribe_v1', [ 'foo' => 'bar' ]);
Now when I try to subscribe to the app with the following code, it gives me authorization denied error:
$.ajax({ type: "POST", url: "https://placeholder_domain.com/fusio/public/consumer/subscription", dataType: 'json', headers: { "Authorization": "Basic " + btoa(username + ":" + password) }, data: { "username": "placeholder_username", "password": "placeholder_key", "event": "subscribe_v1", "endpoint": "https://placeholder_domain.com/fusio/public/index.php/order_call/" }, success: function (result){ console.log(result) } });
Any help would be highly appreciated!