Skip to content

How to access OfferAsync method of Source.Queue when using Akka.Net Graphs? #6928

Answered by Aaronontheweb
alex-vovk asked this question in Q&A
Discussion options

You must be logged in to vote

You just need to pass the Source.Queue<T> in as an input variable when you initially call the GraphDsl - this will allow the graph to have a materialization type, which you can access once the graph is compiled:

var actorSystem = ActorSystem.Create("Test");

// create source
var sourceQueue = Source.Queue<int>(100, OverflowStrategy.Fail);

var graph = GraphDsl.Create(sourceQueue, (builder, source) =>
{
	// connected shapes
	var flow = builder.Add(Flow.Create<int>().Select(i => i * 10));
	var sink = builder.Add(Sink.ForEach<int>(i => Console.WriteLine(i)));
	
	builder.From(source).To(flow);
	builder.From(flow).To(sink);
	
	return ClosedShape.Instance;
});

ISourceQueueWithComplete<int> que…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by alex-vovk
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants