How do I use Laravel notification toArray or toDatabase method with 'database' queue connection - laravel-queue

I asked this question: Laravel notification toArray() not saving data to notifications table and afterwards, I just thought to change my queue connection back to 'sync' from 'database' and I found out that the toArray method saved to the notifications table.
I'm not sure there's anything in the docs under notifications or queues about a specific queue connection to use with the toArray or toDatabase methods.
Is it that these methods don't work with 'database' queue connection or there's something else I need to do to make them work together?

Clear the cache of your application
php artisan optimize:clear

Related

Asterisk do not sees queue members

I have realtimequeue. After restarting asterisk do not sees queue members. When execute on cli this command “queue pause member SIP/111” get this error.
Unable to pause interface 'SIP/111’
Command ‘queue pause member SIP/111’ failed.
But after execute this command “queue show” Asterisk sees all queue members.
Note: I use realtime config.
[settings]
queues => odbc,asteriskdb,queue_table
queue_members => odbc,asteriskdb,queue_member_table
queue_log => odbc,asteriskdb,queue_log
That is normal behavour for realtime queues.
However they still can work and queue will be fetched on first request. It designed so to support thousands of "lazy" queues.
If you want it always be in memory, use realtime config store method.

Restoring messages from database

I am thinking of a way to manage failed messages in Rebus.
In my second level retry strategy I want to save the message and exception details into the database so that I can later review the error details and decide whether to resend the message to the be reprocessed or ignore and delete.
In the handler I am capturing details as follows:
public async Task Handle(IFailed<StudentCreated> failedMessage)
{
//Logic to Defer Message with rebus_defer_count not shown
DictionarySerializer dictionarySerializer = new
DictionarySerializer();
ObjectSerializer objectSerializer = new ObjectSerializer();
string headers =
dictionarySerializer.SerializeToString(failedMessage.Headers);
string message =
objectSerializer.SerializeToString(failedMessage.Message);
Exception lastException= failedMessage.Exceptions.Last();
string exception = objectSerializer.SerializeToString(lastException);
//Logic to save the message and error details in the database not shown
}
This will enable me to save the message and error details into the database where I can create a dashboard to view the messages and resolve them as I wish rather than in the broker queue such as RabbitMQ.
Now my question is how can I return them to the handler where the error was raised using the information provided in the headers?
What is the best way to do it with REBUS provided I have all the details from the Failed Message as shown in my code snippet?
Regards
What you're trying to achieve will be much easier if you make a small change to your application. You see, Rebus already has a built-in service in place for handling failed messages called IErrorHandler.
You can register your own error handler like this:
Configure.With(...)
.(...)
.Options(o => o.Register<IErrorHandler>(c => new MyCustomErrorHandler()))
.Start();
thus replacing the default error handler (which btw. is PoisonQueueErrorHandler)
The error handler gets to handle the message in the form of the raw TransportMessage (i.e. simply headers and a byte[]) when all retries have failed, so this is the perfect place to save the message to your database.
If you then look here, you can see how Rebus' default error handler adds its own queue name as the rbs2-source-queue header, meaning that the message can later be sent back to that queue.
With this information, it should be fairly easy to write some code that inspects the message for its source queue and sends a RabbitMQ message to that queue.
This will only work if the re-delivery service has access to the RabbitMQ instance where all of your Rebus endpoints are running, of course. It's less straightforward, if you want to implement this in a general way: E.g. if you were using Fleet Manager, each Rebus instance would use a long-polling protocol to query the server for commands, which enables Fleet Manager to tell any Rebus instance to e.g. send a previously failed message to any queue it has access to.

propagate OpenTracing TraceIds from publisher to consumer using MassTransit.RabbitMQ

Using MassTransit.RabbitMQ v5.3.2 and OpenTracing.Contrib.NetCore v0.5.0.
I'm able publish and consume events to RabbitMQ using MassTransit and I've got OpenTracing working with Jaeger, but I haven't managed to get my OpenTracing TraceIds propogated from my message publisher to my message consumer - The publisher and consumer traces have different TraceIds.
I've configured MassTransit with the following filter:
cfg.UseDiagnosticsActivity(new DiagnosticListener("test"));
I'm not actually sure what the listener name should be, hence "test". The documentation doesn't have an example for OpenTracing. Anyways, this adds a 'Publishing Message' span to the active trace on the publish side, and automatically sets up a 'Consuming Message' trace on the consumer side; however they're separate traces. How would I go about consolidating this into a single trace?
I could set a TraceId header using:
cfg.ConfigureSend(configurator => configurator.UseExecute(context => context.Headers.Set("TraceId", GlobalTracer.Instance.ActiveSpan.Context.TraceId)))
but then how would I configure my message consumer so that this is the root TraceId? Interested to see how I might do this, or if there's a different approach...
Thanks!
If anyone is interested; I ended up solving this by creating some publish and consume MassTransit middleware to do the trace propagation via trace injection and extraction respectively.
I've put the solution up on GitHub - https://github.com/yesmarket/MassTransit.OpenTracing
Still interested to hear if there's a better way of doing this...

Issue with Notification and Disconnect

We are trying to upgrade existing app with your framework, other things are working fine like connection/read/write however we are facing issues with Notification/Disconnect
Can you please guide for following scenarios:-
Need call back for disconnection
Notification not working we are not able to receive any notification alert
Is there any method to check characteristics of devices, as we have different devices and some characteristics are not present in all devices, when we try to read/write non present chacraterstics on devices, it throws exception and app crashes
Code :-
connection.writeDescriptor(
Defs.SVC_AUTOMATIONIO_UUID,
Defs.CHAR_AUTOMATION_IO,
Defs.DESC_CLIENT_CHAR_CONFIGURATION_UUID,
BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE
)
.subscribe(
this::onWriteSuccess,
this::onWriteFailure
);
connection.setupNotification(iCharUuid)
.flatMap(notificationObservable -> notificationObservable)
.subscribe(
this::onNotificationReceived,
this::onConnectionFailure
);
Thanks
Swayam
In general you don't have to write descriptor manually to enable notifications. The library does it for you.
Try: (example)
rxBleConnection.setupNotification(Defs.DESC_CLIENT_CHAR_CONFIGURATION_UUID)
.flatMap(notificationObservable -> notificationObservable)
.subscribe(this::onNotificationReceived, this::onNotificationSetupFailure);
In order to get callback for disconnection: (example)
You can observe onError from establishConnection method.
You can setup connection status observable
bleDevice.observeConnectionStateChanges().subscribe(this::onConnectionStateChange);
To check characteristics you can go with service discovery: (example)
bleDevice.establishConnection(this, false)
.flatMap(RxBleConnection::discoverServices)
.first() // Disconnect automatically after discovery
.subscribe(this::processDiscoveredServices, this::onConnectionFailure);

What is mean by Action => 'ping' using send_action in Asterisk Manager Interface script?

I have started to read about Asterisk::AMI module.
In that module if we want to send the action to the AMI server,we need to use the Action with action name using send_action method.
In that module they mentioned about Action => 'Ping' within send_action method.
Here what is the use of Action => 'Ping'.Can anyone explain me about it.
send_action({ Action => 'Ping',
CALLBACK => \&method,
});
Thanks in advance.
The Asterisk Manager Interface (AMI) allows a client program to connect to an Asterisk instance and issue commands or read events over a TCP/IP stream
Action: A packet sent by the connected client to Asterisk, requesting a particular Action be performed. There are a finite (but extendable) set of actions available to the client, determined by the modules presently loaded in the Asterisk engine. Only one action may be outstanding at a time
Action => Ping
gives Keep alive packet to be sent from the client to Astersik
Action: Ping
Synopsis: Keepalive command
Privilege: <none>
Description: A 'Ping' action will elicit a 'Pong' response. Used to keep the
manager connection open.
Variables: NONE
You can get basic help for any Asterisk AMI command from within the Asterisk CLI
interface by typing
manager show command yourCommand
You can see an entire list of supported commands by typing
manager show commands
BTW the shell command to get to the Asterisk CLI is
asterisk -r
I think this is a just a keep alive. Asterisk Manager Interface is known for being a little unreliable. Astmanproxy is a good way to fix that.

Resources