{"action":"created","issue":{"url":"https://api.github.com/repos/quarkusio/quarkus/issues/2981","repository_url":"https://api.github.com/repos/quarkusio/quarkus","labels_url":"https://api.github.com/repos/quarkusio/quarkus/issues/2981/labels{/name}","comments_url":"https://api.github.com/repos/quarkusio/quarkus/issues/2981/comments","events_url":"https://api.github.com/repos/quarkusio/quarkus/issues/2981/events","html_url":"https://github.com/quarkusio/quarkus/issues/2981","id":460936817,"node_id":"MDU6SXNzdWU0NjA5MzY4MTc=","number":2981,"title":"ContextNotActiveException when using SuspendableContainerRequestContext","user":{"login":"csotiriou","id":1228484,"node_id":"MDQ6VXNlcjEyMjg0ODQ=","avatar_url":"https://avatars3.githubusercontent.com/u/1228484?v=4","gravatar_id":"","url":"https://api.github.com/users/csotiriou","html_url":"https://github.com/csotiriou","followers_url":"https://api.github.com/users/csotiriou/followers","following_url":"https://api.github.com/users/csotiriou/following{/other_user}","gists_url":"https://api.github.com/users/csotiriou/gists{/gist_id}","starred_url":"https://api.github.com/users/csotiriou/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/csotiriou/subscriptions","organizations_url":"https://api.github.com/users/csotiriou/orgs","repos_url":"https://api.github.com/users/csotiriou/repos","events_url":"https://api.github.com/users/csotiriou/events{/privacy}","received_events_url":"https://api.github.com/users/csotiriou/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2019-06-26T12:18:19Z","updated_at":"2019-06-26T12:52:25Z","closed_at":null,"author_association":"NONE","body":"I am using Mongo (JVM, I do not care about native) as a pre-request filter, in order to get some data from the MongoDB before it reaches the actual Resource.\r\n\r\nMongo Driver is asynchronous by nature, so I call `suspend()` before I start making the call. However, when trying to do `resume()`, I get a `javax.enterprise.context.ContextNotActiveException`.\r\n\r\n\r\nThe following is written in the `public void filter(ContainerRequestContext requestContext)` function of a `ContainerRequestFilter`\r\n\r\n```\r\nSuspendableContainerRequestContext suspendableContainerRequestContext = (SuspendableContainerRequestContext) requestContext;\r\n\r\n        suspendableContainerRequestContext.suspend();\r\n\r\n        MongoCollection collection = mongoConfig.getAssetCachingCollection(); //this is the mongo collection\r\n        FindPublisher publisher = collection.find(eq(\"_id\", idForSearch)).maxTime(1, TimeUnit.SECONDS);\r\n\r\n        Subscriber<Document> subscriber = new Subscriber<Document>() {\r\n            @Override\r\n            public void onSubscribe(Subscription s) {\r\n                s.request(1);\r\n            }\r\n\r\n            @Override\r\n            public void onNext(Document document) {\r\n                //this never gets called\r\n            }\r\n\r\n            @Override\r\n            public void onError(Throwable t) {\r\n                System.out.println(\"error: \" + t.toString());\r\n                //TODO\r\n            }\r\n\r\n            @Override\r\n            public void onComplete() {\r\n                System.out.println(\"completed\");\r\n                suspendableContainerRequestContext.resume(); //CRASHES! Context Not Active?\r\n            }\r\n        };\r\n\r\n        publisher.subscribe(subscriber);\r\n```\r\n\r\nWhen the `onComplete()` is called, I get the `ContextNotActiveException`.\r\n\r\n```\r\njavax.enterprise.context.ContextNotActiveException: interface javax.enterprise.context.RequestScoped\r\n```"},"comment":{"url":"https://api.github.com/repos/quarkusio/quarkus/issues/comments/505861478","html_url":"https://github.com/quarkusio/quarkus/issues/2981#issuecomment-505861478","issue_url":"https://api.github.com/repos/quarkusio/quarkus/issues/2981","id":505861478,"node_id":"MDEyOklzc3VlQ29tbWVudDUwNTg2MTQ3OA==","user":{"login":"FroMage","id":179265,"node_id":"MDQ6VXNlcjE3OTI2NQ==","avatar_url":"https://avatars3.githubusercontent.com/u/179265?v=4","gravatar_id":"","url":"https://api.github.com/users/FroMage","html_url":"https://github.com/FroMage","followers_url":"https://api.github.com/users/FroMage/followers","following_url":"https://api.github.com/users/FroMage/following{/other_user}","gists_url":"https://api.github.com/users/FroMage/gists{/gist_id}","starred_url":"https://api.github.com/users/FroMage/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/FroMage/subscriptions","organizations_url":"https://api.github.com/users/FroMage/orgs","repos_url":"https://api.github.com/users/FroMage/repos","events_url":"https://api.github.com/users/FroMage/events{/privacy}","received_events_url":"https://api.github.com/users/FroMage/received_events","type":"User","site_admin":false},"created_at":"2019-06-26T12:52:25Z","updated_at":"2019-06-26T12:52:25Z","author_association":"MEMBER","body":"You should use MP-CP. You can inject a `ThreadContext` object and use its methods to wrap your calls. If your underlying mongo client uses RxJava2 it should work OOTB (if you depend on `smallrye-context-propagation-propagators-rxjava2`).\r\n\r\nI don't think we can use `ThreadContext` to wrap `Publisher` because it does not depend on RS, but we could make a case for it in the spec."}}
{"actor":{"display_login":"FroMage"}}