channel

spring integration : response message not sent to client from error-channel

此生再无相见时 提交于 2020-01-24 13:03:05
问题 I've the understanding that Spring Integration (SI) will wrap any exception (under the SI domain) to a MessageException instance and place it on the "error-channel". Following are few snippets from my spring config file : <int:channel-interceptor pattern="ersServiceReqRcvPostValidationChannel,ersServiceResRcvPostValidationChannel" order="1"> <bean class="com.bnym.ecs.report.service.orchestration.interceptors.MsgJSONSyntaxValidationInterceptor"/> </int:channel-interceptor> <int:channel

Passing a channel of things as a channel of interfaces in Go

人走茶凉 提交于 2020-01-23 01:43:13
问题 My program has a pipeline structure, and I just implemented a caching filter that sends stuff directly to output if the already processed version of data is in the cache. func Run(in chan downloader.ReadyDownload) chan CCFile { out := make(chan CCFile) processQueue := make(chan downloader.ReadyDownload) go cache.BypassFilter(in, processQueue, out) // writes the cached, already processed version to out if it exists // otherwise redirects the input to processQueue go process(processQueue, out)

Tcl C API: redirect stdout of embedded Tcl interp to a file without affecting the whole program

a 夏天 提交于 2020-01-22 03:05:11
问题 #include <tcl.h> int main(int argc, char** argv) { Tcl_Interp *interp = Tcl_CreateInterp(); Tcl_Channel stdoutChannel = Tcl_GetChannel(interp, "stdout", NULL); Tcl_UnregisterChannel(interp, stdoutChannel); Tcl_Channel myChannel = Tcl_OpenFileChannel(interp, "/home/aminasya/nlb_rundir/imfile", "w", 0744); Tcl_RegisterChannel(interp, myChannel); Tcl_Eval(interp, "puts hello"); } In this code I have tried to close stdout channel and redirect it to file. (As described Get the output from Tcl C

Send stdin keystrokes to channel without newline required

你说的曾经没有我的故事 提交于 2020-01-21 11:02:11
问题 I'd like to send the user's keystrokes to a channel directly after each individual keystroke is made to stdin. I've attempted the code below, but this doesn't give the desired result because the reader.ReadByte() method blocks until newline is entered. func chars() <-chan byte { ch := make(chan byte) reader := bufio.NewReader(os.Stdin) go func() { for { char, err := reader.ReadByte() if err != nil { log.Fatal(err) } ch <- char } }() return ch } Thank you for any advice on how might I get each

Are goroutines garbage collected together with their channels?

巧了我就是萌 提交于 2020-01-14 08:59:10
问题 Imagine the following code: func waitForOneOfTwoProcesses() { c := make(chan bool) go func() { time.Sleep(1 * time.Second) c<-true }() go func() { time.Sleep(2 * time.Second) c<-true }() <-c } Does this leak a channel and a goroutine or does Go recognize that c is gone and the goroutine can exit? Would the answer be any different if the channel had a buffer size of 2? 回答1: If the channel is unbuffered, then one of the anonymous functions will not return. The program leaks a goroutine and

Idiomatic way to make a request-response communication using channels

不打扰是莪最后的温柔 提交于 2020-01-12 03:22:29
问题 Maybe I'm just not reading the spec right or my mindset is still stuck with older synchronization methods, but what is the right way in Go to send one type as receive something else as a response? One way I had come up with was package main import "fmt" type request struct { out chan string argument int } var input = make(chan *request) var cache = map[int]string{} func processor() { for { select { case in := <- input: if result, exists := cache[in.argument]; exists { in.out <- result }

Multiple commands using JSch

夙愿已清 提交于 2020-01-09 05:29:25
问题 My requirement is as follow: I have to login to Unix box using my credentials and once login, I have to do sudo to different user. Once sudo is successful, I have to invoke shell in nohup. On completion of executions, close channel and session both. I tried the first step which is connect using sudo command, but I don't know how to invoke shell script after the sudo command. In the below code I am able to execute sudo command, but after getting sudo access how can I execute a shell in nohup

Multiple commands using JSch

ⅰ亾dé卋堺 提交于 2020-01-09 05:29:16
问题 My requirement is as follow: I have to login to Unix box using my credentials and once login, I have to do sudo to different user. Once sudo is successful, I have to invoke shell in nohup. On completion of executions, close channel and session both. I tried the first step which is connect using sudo command, but I don't know how to invoke shell script after the sudo command. In the below code I am able to execute sudo command, but after getting sudo access how can I execute a shell in nohup

Goroutine does not execute if time.Sleep included

让人想犯罪 __ 提交于 2020-01-08 17:17:07
问题 The following code runs perfectly fine: package main import ( "fmt" ) func my_func(c chan int){ fmt.Println(<-c) } func main(){ c := make(chan int) go my_func(c) c<-3 } playgound_1 However if I change c<-3 to time.Sleep(time.Second) c<-3 playground_2 My code does not execute. My gut feeling is that somehow main returns before the my_func finishes executing, but it seems like adding a pause should not have any effect. I am totally lost on this simple example, what's going on here? 回答1: When

MVC2 throws InvalidOperationException in UpdateModel(), trying to update the id field

怎甘沉沦 提交于 2020-01-07 05:37:06
问题 My MVC2 app is giving me grief today... I want to edit a database record, using the following Controller code: [AcceptVerbs(HttpVerbs.Post), Authorize(Roles = "Admin")] public virtual ActionResult Edit(int id, FormCollection formValues) { var masterDataProxy = MasterDataChannelFactory.OpenChannel(); var tester = masterDataProxy.GetTester(id); masterDataProxy.CloseChannel(); if (null == tester) { return View(Views.NotFound); } try { UpdateModel(tester); var adminProxy = AdminChannelFactory