Comments (5)
Hi @tommyseus,
What version of nats streaming is it?
Could you explain your use case and flow that triggers this?
from php-nats-streaming.
I'm sorry, the exception has a different cause.
The error is triggered by the next message. There are 2 messages published. But the subscribe handles only one (wait (1)) and than unsubscribed from the subject. Between wait and unsubscribe the second message has arrieved. I have added a sleep so that the error always occurs for demonstration.
publisher.php :
<?php
require __DIR__ . '/vendor/autoload.php';
ini_set('display_errors', '1');
$options = new Nats\ConnectionOptions();
$options->setHost('da-nats-streaming');
$streamingOptions = new \NatsStreaming\ConnectionOptions();
$streamingOptions->setClientID(uniqid('test_', false));
$streamingOptions->setClusterID("test-cluster");
$streamingOptions->setNatsOptions($options);
$streamingConnection = new \NatsStreaming\Connection($streamingOptions);
$streamingConnection->connect(60);
// publish
for ($i = 1; $i <= 4; ++$i) {
$request = $streamingConnection->publish('dummy-subject', "publish $i - " . date('Y-m-d H:i:s'));
$request->wait();
var_dump($request->gotAck());
}
subscriber.php :
<?php
require __DIR__ . '/vendor/autoload.php';
ini_set('display_errors', '1');
$options = new Nats\ConnectionOptions();
$options->setHost('da-nats-streaming');
$streamingOptions = new \NatsStreaming\ConnectionOptions();
$streamingOptions->setClientID(uniqid('dummy-client-id'));
$streamingOptions->setClusterID("test-cluster");
$streamingOptions->setNatsOptions($options);
$streamingConnection = new \NatsStreaming\Connection($streamingOptions);
$streamingConnection->connect(60);
// subscribe
$subscriptionOptions = new NatsStreaming\SubscriptionOptions();
$subscriptionOptions->setAckWaitSecs(10);
$subscriptionOptions->setManualAck(true);
$subscriptionOptions->setDurableName('dummy-durable');
$subscriptionOptions->setMaxInFlight(1);
$subscribe = $streamingConnection->queueSubscribe(
'dummy-subject',
'abcdefghijkl',
function ($message) {
/* @var $message \NatsStreaming\Msg */
echo 'received: ' . $message->getData() . PHP_EOL;
$message->ack();
},
$subscriptionOptions
);
$subscribe->wait(1);
// time to receive the next message from the nats server
sleep(4);
// triggers a wait and consumes the next message. But throws a exception because the subscriber callback was removed.
$subscribe->unsubscribe();
Versions:
nats-streamin: 0.9.2 (https://hub.docker.com/_/nats-streaming/)
byrnedo/php-nats-streaming: 0.2.4
repejota/nats: 0.8.7
from php-nats-streaming.
from php-nats-streaming.
@tommyseus bump, have I grasped the flow?
from php-nats-streaming.
from php-nats-streaming.
Related Issues (12)
- Remove random generator
- Multiple notices when sending messages HOT 2
- How to get length of queue? HOT 1
- phpnats abandoned? HOT 1
- Investigate generators and coroutines for ack/heartbeat processing
- Durable subscription does not ack message HOT 10
- Incorrect behaviour with two consumers on same subject (durable sub) HOT 21
- Fatal error: Uncaught Error: Call to a member function getSid() on null HOT 5
- queue subscription HOT 7
- Very important setting for performance HOT 5
- reconnect to stan(nats streaming) within existing nats connection HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from php-nats-streaming.