I want to use mass transit redelivery for some exception .
according to mass transit document this must be worked :
consumer class :
public async Task Consume(ConsumeContext<SendEmailEvent> context)
{
try
{
...
}
catch (Exception ex)
{
throw new Exception($"email not sent to {email} errors : {ex.Message}", ex);
}
}
start up class :
Uri schedulerEndpoint = new Uri("rabbitmq://localhost/quartz");
services.AddMassTransit(x =>
{
x.AddConsumer<EmailConsumer>();
x.AddBus(provider => Bus.Factory.CreateUsingRabbitMq(cfg =>
{
cfg.UseHealthCheck(provider);
cfg.Host(new Uri("rabbitmq://localhost"), h =>
{
h.Username("guest");
h.Password("guest");
});
cfg.UseMessageScheduler(schedulerEndpoint);
cfg.ReceiveEndpoint("EmailQueue", ep =>
{
ep.UseScheduledRedelivery(r => r.Intervals(TimeSpan.FromMinutes(2), TimeSpan.FromMinutes(3), TimeSpan.FromMinutes(30)));
ep.UseMessageRetry(r => r.Immediate(5));
ep.ConfigureConsumer<EmailConsumer>(provider);
});
}));
});
services.AddMassTransitHostedService();
after 5 Immediate failed attempted (I change consumer implementation to catch error every time) it won't send any request after 2 or 3 mins (Intervals config time) also it does not create 'quartz' Queue .
How can I solve this ?
Related
I have a queue with 100 messages in. At some point, I'd like send a message but this message has a higher priority and should be treated first, before the 100 existing.
Is there a way to do this ?
Thanks,
Tried to set the but no more message arrive :
On the sender (Web API)
var bus = Bus.Factory.CreateUsingRabbitMq(sbc =>
sbc.Host("hostName", "host", h =>
{
h.Username("username");
h.Password("password);
})
);
Send the message
Uri uri = new Uri("queue:myQueue");
var endpoint = await bus.GetSendEndpoint(uri);
await endpoint.Send(request);
On the consumer (consoler app) :
static void Main(string[] args)
{
var busControl = Bus.Factory.CreateUsingRabbitMq(cfg =>
{
cfg.Host("localhost", "/", h =>
{
h.Username("guest");
h.Password("guest");
});
cfg.ReceiveEndpoint("myQueue", e =>
{
e.Handler<myType>(context =>
{
return Console.Out.WriteLineAsync($"{context.Message.Id}");
});
});
});
busControl.Start();
Console.WriteLine("Receive listening for messages");
Console.ReadLine();
busControl.Stop();
}
When configuring a receive endpoint, you can enable priority for that endpoint (queue):
configurator.ReceiveEndpoint("priority_input_queue", x =>
{
x.EnablePriority(4);
x.ConfigureConsumer(...);
});
This would configure the endpoint with maximum allowed priority of four (4).
Then, when sending/publishing a message, the priority can be specified:
await Bus.Publish(new Message(...), context =>
{
context.SetPriority(2);
});
If no value is specified, the default priority is used.
I am trying to join a room with socket io :
socket.join(to, async () => {
console.log('ici')
if (!room) return
try {
const user = await ChatRedis.getUser(room, username)
await ChatRedis.setUser(room, username, { ...user, conference: to })
console.log(admin
? `Conference - User "${username}" opened a conference`
: `Conference - User "${username}" joined the "${to}" conference`)
namespace.in(to).emit('joinConference', { username, to, room, from })
} catch (error) {
console.log(error)
}
})
But the callback version is not working. I am using workspace I do not know if it is the issue
Socket io version : 2.2.0
Express: 4.17.1
When trying to do a user count I get the error web socket is not in open state, I have Saaskit as well for mutitenancy could that be the cause?
I have tried specifieng UseWebsockets in the startup.cs with no luck
{
private static int UserCount;
public override Task OnConnectedAsync()
{
UserCount++;
base.OnConnectedAsync();
this.Clients.All.SendAsync("updateUserCount", UserCount);
return Task.CompletedTask;
}
public override Task OnDisconnectedAsync(Exception exception)
{
UserCount--;
base.OnDisconnectedAsync(exception);
this.Clients.All.SendAsync("updateUserCount", UserCount);
return Task.CompletedTask;
}
}```
```<script>
document.addEventListener('DOMContentLoaded', function () {
}
function onConnectionError(error) {
if (error && error.message) {
console.error(error.message);
}
}
var connection = new
signalR.HubConnectionBuilder().withUrl('/adminHub')
.configureLogging(signalR.LogLevel.Debug).build();
connection.start()
.then(function () {
onConnected(connection);
})
.catch(function (error) {
console.error(error.message);
});
});
</script>```
Debug: Sending handsha`enter code here`ke request.
Debug: Hub handshake failed with error 'WebSocket is not in the OPEN state' during start(). Stopping HubConnection.
HttpConnection.stopConnection(undefined) called while in state Disconnecting.
Connection disconnected with error 'WebSocket is not in the OPEN state'.
HubConnection.connectionClosed(WebSocket is not in the OPEN state) called while in state Connecting.
I know it is late response but this worked for me:
after calling start on connection.
connection.start()
.then(function (data) {
console.log(data);
}).catch(function (err) {
console.log(err);
});
add this property to webSocket Object:
Object.defineProperty(window.WebSocket, 'OPEN', { value: 1, });
Known Issue
I'm really new to this but I already know (by searching other projects through the Internet) that the MiBands have an authentication process.
The thing is I have tried to write without and with response to the only service UUID I got through the connection and it's always saying the band has not that UUID Service.
I am using React-Native-BLE-PLX library.
As it can be seen in the image I use the device's Service UUID since I cannot get any other service but it always says that it does not exist.
search(){
this.manager = new BleManager();
this.manager.startDeviceScan(null, null, (error, device) => {
if (error) {
console.log(error.message);
return;
}
if (device.name == 'Mi Band 3') {
this.manager.stopDeviceScan();
this.device = device;
this.connect();
}
});
}
connect() {
console.log("CONNECTING...");
this.device.connect()
.then(async (device) => {
console.log("CONNECTED!!!");
console.log("DEVICE CONNECTED:\n");
console.log(device);
this.auth(device);
// return this.manager.discoverAllServicesAndCharacteristicsForDevice(device.id)
})
// .then((device) => {
// console.log(device);
// this.send(device);
// })
// .catch((error) => {
// console.log("ERROR: ");
// console.log(error);
// });
}
async auth(device) {
console.log("DEVICE: \n");console.log(this.device);
console.log("DEVICE'S SERVICE UUID: \n" +this.device.serviceUUIDs[0]);
console.log("TRYING");
this.manager.writeCharacteristicWithoutResponseForDevice('D7:2D:F8:F2:24:3F', '0000fee0-0000-1000-8000-00805f9b34fb', '00000009-0000-3512-2118-0009af100700', 0x01 + 0x00 + new Buffer("OLA MUNDO"))
.then((device) => {
console.log("STUFF GOING ON:\n");
console.log(device);
})
.catch((error) => {
throw error;
});
}
Really need help and thanks for that.
If there is something I need to describe more please just tell me.
Directly after getting connected you must first discover the services and characteristics. After that you can start the authentication part. However your authentication part is totally wrong. Do a bit of Googling to find out how to do it properly...
It is not connecting to the websocket server.I am using webstomp-client for react native.Plz, help me !
Here is my code,
componentWillMount() {
let msg = '';
const options = {
debug: true,
protocols: webstomp.VERSIONS.supportedProtocols()
}
this.stompClient = webstomp.client("ws://192.168.3.167:8080/test", options)
this.stompClient.connect({}, (frame) => {
console.log("OK")
this.stompClient.subscribe('/topic/greetings', (greeting) => {
msg = JSON.parse(greeting.body);
});
this.setState({
connected: true,
message: msg
})
}, (err) => console.log(err))
}
and logs...
Opening Web Socket...
webstomp.js:243 Web Socket Opened...
webstomp.js:243 >>> CONNECT
accept-version:1.2,1.1,1.0
heart-beat:10000,10000
Thanks in advance.
Got the same issue. Had to implement a custom WebSocketHandlerDecorator with:
public void handleMessage(final WebSocketSession session, final WebSocketMessage<?> message) throws Exception {
if (message instanceof TextMessage) {
TextMessage msg = (TextMessage) message;
String payload = msg.getPayload();
// only add \00 if not present (iOS / Android)
if (!payload.substring(payload.length() - 1).equals("\u0000")) {
super.handleMessage(session, new TextMessage(payload + "\u0000"));
return;
}
}
super.handleMessage(session, message);
}
Based on https://github.com/facebook/react-native/issues/12731