Monthly Archives: April 2011

Named Pipes고정닉 파이프

http://msdn.microsoft.com/en-us/library/aa365590(v=VS.85).aspx

Named Pipes

named pipe is a named, one-way or duplex pipe for communication between the pipe server and one or more pipe clients. All instances of a named pipe share the same pipe name, but each instance has its own buffers and handles, and provides a separate conduit for client/server communication. The use of instances enables multiple pipe clients to use the same named pipe simultaneously.

네임드 파이프는 pipe server과 한개 이상의 pipe clients간의 단방향 또는 양방향 커뮤니케이션을 하는 파이프다. 네임드 파이프는 동일한 파이프 이름을 갖지만share 각각의 인스턴스instance는 각자 버퍼buffers와 핸들handles를 갖고 클라이언트/서버간 커뮤니케이션 통로를 제공한다.  instance를 쓰면 여러 pipe client가 동시에 같은 이름의 파이프를 쓸 수 있다.

Any process can access named pipes, subject to security checks, making named pipes an easy form of communication between related or unrelated processes. 어떤 프로세스건 보안체크만 하면 네임드 파이프에 접근할 수 있다.

네임드 파이프는 쉬운 communication방법이다. 그게 연관된 프로세스이건 연관없는 프로세스이건간에..

Any process can act as both a server and a client, making peer-to-peer communication possible. As used here, the term pipe server refers to a process that creates a named pipe, and the term pipe client refers to a process that connects to an instance of a named pipe. The server-side function for instantiating a named pipe isCreateNamedPipe. The server-side function for accepting a connection is ConnectNamedPipe. A client process connects to a named pipe by using the CreateFileor CallNamedPipe function.

모든 프로세스는 서버나 클라이언트가 되서 p2p통신을 할 수 있다. 네임드 파이프를 만드는것이 서버, 네임드 파이프에 접속하는게 클라이언트다. 서버에서 네임드 파이프를 만드는 것은 CreateNamedPipe함수. 서버에서 네임드 파이프에 접속하는것은 ConnectNamedPipe함수. 클라이언츠에서 네임드 파이프에 접속하는것은 CreateFile 또는 CallNamedPipe 함수이다.

Named pipes can be used to provide communication between processes on the same computer or between processes on different computers across a network. If the server service is running, all named pipes are accessible remotely. If you intend to use a named pipe locally only, deny access to NT AUTHORITYNETWORK or switch to local RPC.

네임브 파이프는 로컬 컴퓨터나 리모트 컴퓨터에서 모두 접속이 가능하다. server service가 실행중이라면 모든 네임드 파이프는 원격 접속이 가능하다. 네임드 파이프를 로컬에서만 사용할 생각이라면 NT AUTHORITY/NETWORK를 꺼 놓던가 local RPC로 돌려놔라?

For more information, see the following topics:

 

 

Send comments about this topic to Microsoft

Build date: 1/27/2011

 

Anonymous Pipes

http://msdn.microsoft.com/en-us/library/aa365139(v=VS.85).aspx

An anonymous pipe is an unnamed, one-way pipe that typically transfers data between a parent process and a child process. Anonymous pipes are always local; they cannot be used for communication over a network.

이름없는 파이프는 one-way pipe이고 일반적으로 parent 프로세스와 child프로세스 사이의 통신에 이용된다.  이름없는 파이프는 항상 로컬에서만 사용된다. 네트워크 통신에는 사용할 수 없다.

For more information, see the following topics:

 

 

Send comments about this topic to Microsoft

Build date: 1/27/2011

 

About Pipes 파이프는

http://msdn.microsoft.com/en-us/library/aa365137(v=VS.85).aspx

There are two types of pipes: anonymous pipes and named pipes. Anonymous pipes require less overhead than named pipes, but offer limited services.

두 가지 형태의 파이프 : 익명파이프, 이름드파이프. 익명 파이프는 이름드파이프보다 부하가 적지만 서비스 요청이 제한된다.

The term pipe, as used here, implies that a pipe is used as an information conduit. Conceptually, a pipe has two ends. A one-way pipe allows the process at one end to write to the pipe, and allows the process at the other end to read from the pipe. A two-way (or duplex) pipe allows a process to read and write from its end of the pipe.

여기서 파이프라는 것은 정보의 전송로이다. 개념적으로 파이프는 두 끝부분이 있다. 한개는 데이터 입구 한개는 데이터 출구…

two-way 파이프는 양쪽 끝에도 모두 읽고 쓸 수 있다.

 

 

Send comments about this topic to Microsoft

Build date: 1/27/2011

 

Pipes 파이프 통신

http://msdn.microsoft.com/en-us/library/aa365780(v=VS.85).aspx

pipe is a section of shared memory that processes use for communication. The process that creates a pipe is the pipe server. A process that connects to a pipe is a pipe client. One process writes information to the pipe, then the other process reads the information from the pipe. This overview describes how to create, manage, and use pipes.

파이프는 프로세스가 통신용으로 사용하는 공유 메모리이다. 파이프를 생성하는 프로세스는 pipe server가 되고 파이프에 접속하는 프로세스는 pipe client가 된다. 한 프로세스가 pipe에 information을 쓰고 다른 프로세스는 그것을 읽는다. 이 개요overview는 pipe를 어떻게 생성하고 관리하고 사용하는지 설명하고 있다.

 

 

Send comments about this topic to Microsoft

Build date: 1/27/2011

 

Interprocess Communications프로세스간 통신방법들

http://msdn.microsoft.com/en-us/library/aa365574(v=VS.85).aspx

The Windows operating system provides mechanisms for facilitating communications and data sharing between applications. Collectively, the activities enabled by these mechanisms are called interprocess communications (IPC). Some forms of IPC facilitate the division of labor among several specialized processes. Other forms of IPC facilitate the division of labor among computers on a network.

윈도우는 어플리케이션간의 쉬운 커뮤니케이션과 데이터 공유를 위한 매커니즘을 제공한다. 이런 매커니즘을 통틀어서 IPC(interprocess communications)라고 부른다. 몇몇 IPC는 프로세스의 분업을 도와준다. 다른 IPC들은 네트워크의 컴퓨터 사이의 분업을 도와준다.

Typically, applications can use IPC categorized as clients or servers. A client is an application or a process that requests a service from some other application or process. A server is an application or a process that responds to a client request. Many applications act as both a client and a server, depending on the situation. For example, a word processing application might act as a client in requesting a summary table of manufacturing costs from a spreadsheet application acting as a server. The spreadsheet application, in turn, might act as a client in requesting the latest inventory levels from an automated inventory control application.

보통 IPC를 쓰는 어플리케이션은 client와 server로 분류된다. client는 서비스를 요청한다. server는 client의 요청에 응답한다.  대부분의 어플리케이션은 상황에 따라 client가 되기도 하고 server가 되기도 한다. 예를들어, 워드프로세서가 스프레드시트에 생산원가에 대한 표를 요청할 때 워드프로세서는 client가 되고 스트레드시트는 server가 된다. 스트레드시트가 재고관리 어플리케이션에 마지막 재고 상황을 요청할 때는 client가 된다.

After you decide that your application would benefit from IPC, you must decide which of the available IPC methods to use. It is likely that an application will use several IPC mechanisms. The answers to these questions determine whether an application can benefit by using one or more IPC mechanisms.

IPC를 쓰기로 결정했다면… 어떤 IPC방식을 사용할지도 결정해야한다. 어플리케이션은 보통 몇 가지 IPC 메커니즘을 사용한다. 다음 질문의 답변을 통해 IPC메커니즘을 사용하는 것이 어떤 잇점이 있는지 알 수 있을 것이다.

  • Should the application be able to communicate with other applications running on other computers on a network, or is it sufficient for the application to communicate only with applications on the local computer?
  • Should the application be able to communicate with applications running on other computers that may be running under different operating systems (such as 16-bit Windows or UNIX)?
  • Should the user of the application have to choose the other applications with which the application communicates, or can the application implicitly find its cooperating partners?
  • Should the application communicate with many different applications in a general way, such as allowing cut-and-paste operations with any other application, or should its communications requirements be limited to a restricted set of interactions with specific other applications?
  • Is performance a critical aspect of the application? All IPC mechanisms include some amount of overhead. 성능(속도?)이 중요한가? 모든 IPC 메커니즘은 오버헤드가 필요하다.
  • Should the application be a GUI application or a console application? Some IPC mechanisms require a GUI application. 어플리케이션이 GUI인가 Console인가? 몇몇 IPC는 GUI환경이 필요하다.

The following IPC mechanisms are supported by Windows:

윈도우에서 아래의 IPC메커니즘이 제공된다.

Using the Clipboard for IPC

The clipboard acts as a central depository for data sharing among applications. When a user performs a cut or copy operation in an application, the application puts the selected data on the clipboard in one or more standard or application-defined formats. Any other application can then retrieve the data from the clipboard, choosing from the available formats that it understands. The clipboard is a very loosely coupled exchange medium, where applications need only agree on the data format. The applications can reside on the same computer or on different computers on a network.

Key Point: All applications should support the clipboard for those data formats that they understand. For example, a text editor or word processor should at least be able to produce and accept clipboard data in pure text format. For more information, see Clipboard.

Using COM for IPC

Applications that use OLE manage compound documents— that is, documents made up of data from a variety of different applications. OLE provides services that make it easy for applications to call on other applications for data editing. For example, a word processor that uses OLE could embed a graph from a spreadsheet. The user could start the spreadsheet automatically from within the word processor by choosing the embedded chart for editing. OLE takes care of starting the spreadsheet and presenting the graph for editing. When the user quit the spreadsheet, the graph would be updated in the original word processor document. The spreadsheet appears to be an extension of the word processor.

The foundation of OLE is the Component Object Model (COM). A software component that uses COM can communicate with a wide variety of other components, even those that have not yet been written. The components interact as objects and clients. Distributed COM extends the COM programming model so that it works across a network.

Key Point: OLE supports compound documents and enables an application to include embedded or linked data that, when chosen, automatically starts another application for data editing. This enables the application to be extended by any other application that uses OLE. COM objects provide access to an object’s data through one or more sets of related functions, known as interfaces. For more information, see COM and ActiveX Object Services.

Using Data Copy for IPC

Data copy enables an application to send information to another application using the WM_COPYDATA message. This method requires cooperation between the sending application and the receiving application. The receiving application must know the format of the information and be able to identify the sender. The sending application cannot modify the memory referenced by any pointers.

WM_COPYDATA메세지를 통해 데이터를 전송한다. 이 방법을 쓰려면 두 어플리케이션이 같이 동작해야된다. 두 어플리케이션은 정해진 format을 사용해야한다. 보내는 어플리케이션은 메모리 레퍼런스나 포인터를 건드릴 수 없다.

Key Point: Data copy can be used to quickly send information to another application using Windows messaging. For more information, see Data Copy.
Data copy는 윈도우즈 메세지를 통해 빠르게 데이터를 전송할 수 있다.

Using DDE for IPC

DDE is a protocol that enables applications to exchange data in a variety of formats. Applications can use DDE for one-time data exchanges or for ongoing exchanges in which the applications update one another as new data becomes available.

The data formats used by DDE are the same as those used by the clipboard. DDE can be thought of as an extension of the clipboard mechanism. The clipboard is almost always used for a one-time response to a user command, such as choosing the Paste command from a menu. DDE is also usually initiated by a user command, but it often continues to function without further user interaction. You can also define custom DDE data formats for special-purpose IPC between applications with more tightly coupled communications requirements.

DDE exchanges can occur between applications running on the same computer or on different computers on a network.

Key Point: DDE is not as efficient as newer technologies. However, you can still use DDE if other IPC mechanisms are not suitable or if you must interface with an existing application that only supports DDE. For more information, see Dynamic Data Exchange and Dynamic Data Exchange Management Library.

Using a File Mapping for IPC

File mapping enables a process to treat the contents of a file as if they were a block of memory in the process’s address space. The process can use simple pointer operations to examine and modify the contents of the file. When two or more processes access the same file mapping, each process receives a pointer to memory in its own address space that it can use to read or modify the contents of the file. The processes must use a synchronization object, such as a semaphore, to prevent data corruption in a multitasking environment.

You can use a special case of file mapping to provide named shared memory between processes. If you specify the system swapping file when creating a file-mapping object, the file-mapping object is treated as a shared memory block. Other processes can access the same block of memory by opening the same file-mapping object.

File mapping is quite efficient and also provides operating-system–supported security attributes that can help prevent unauthorized data corruption. File mapping can be used only between processes on a local computer; it cannot be used over a network.

Key Point: File mapping is an efficient way for two or more processes on the same computer to share data, but you must provide synchronization between the processes. For more information, see File Mapping and Synchronization.

Using a Mailslot for IPC

Mailslots provide one-way communication. Any process that creates a mailslot is a mailslot server. Other processes, called mailslot clients, send messages to the mailslot server by writing a message to its mailslot. Incoming messages are always appended to the mailslot. The mailslot saves the messages until the mailslot server has read them. A process can be both a mailslot server and a mailslot client, so two-way communication is possible using multiple mailslots.

A mailslot client can send a message to a mailslot on its local computer, to a mailslot on another computer, or to all mailslots with the same name on all computers in a specified network domain. Messages broadcast to all mailslots on a domain can be no longer than 400 bytes, whereas messages sent to a single mailslot are limited only by the maximum message size specified by the mailslot server when it created the mailslot.

Key Point: Mailslots offer an easy way for applications to send and receive short messages. They also provide the ability to broadcast messages across all computers in a network domain. For more information, see Mailslots.

Using Pipes for IPC

There are two types of pipes for two-way communication: anonymous pipes and named pipes. Anonymous pipes enable related processes to transfer information to each other. Typically, an anonymous pipe is used for redirecting the standard input or output of a child process so that it can exchange data with its parent process. To exchange data in both directions (duplex operation), you must create two anonymous pipes. The parent process writes data to one pipe using its write handle, while the child process reads the data from that pipe using its read handle. Similarly, the child process writes data to the other pipe and the parent process reads from it. Anonymous pipes cannot be used over a network, nor can they be used between unrelated processes.

두 가지 타입의 pipe의 2웨이 통신 : anonymous pipe와 named pipe. Anonymous pipe는 관련 프로세스가 서로 정보를 주고받을 수 있다. 보통 anonymous pipe는 표준 input output을 child 프로세스에 redirecting 한다??.

Named pipes are used to transfer data between processes that are not related processes and between processes on different computers. Typically, a named-pipe server process creates a named pipe with a well-known name or a name that is to be communicated to its clients. A named-pipe client process that knows the name of the pipe can open its other end, subject to access restrictions specified by named-pipe server process. After both the server and client have connected to the pipe, they can exchange data by performing read and write operations on the pipe.

 

Key Point: Anonymous pipes provide an efficient way to redirect standard input or output to child processes on the same computer. Named pipes provide a simple programming interface for transferring data between two processes, whether they reside on the same computer or over a network. For more information, see Pipes.
Anonymous pipe는 같은 컴퓨터에서 실행되는 child 프로세스에 효율적으로 표준 input output을 redirect 해 준다. Named pipe는 같은 컴퓨터 또는 같은 네트워크 안의 두 프로세스간에 간편하게 데이터 전달 통로를 제공 해 준다.

Using RPC for IPC

RPC enables applications to call functions remotely. Therefore, RPC makes IPC as easy as calling a function. RPC operates between processes on a single computer or on different computers on a network.

The RPC provided by Windows is compliant with the Open Software Foundation (OSF) Distributed Computing Environment (DCE). This means that applications that use RPC are able to communicate with applications running with other operating systems that support DCE. RPC automatically supports data conversion to account for different hardware architectures and for byte-ordering between dissimilar environments.

RPC clients and servers are tightly coupled but still maintain high performance. The system makes extensive use of RPC to facilitate a client/server relationship between different parts of the operating system.

Key Point: RPC is a function-level interface, with support for automatic data conversion and for communications with other operating systems. Using RPC, you can create high-performance, tightly coupled distributed applications. For more information, see Microsoft RPC Components.

Using Windows Sockets for IPC

Windows Sockets is a protocol-independent interface. It takes advantage of the communication capabilities of the underlying protocols. In Windows Sockets 2, a socket handle can optionally be used as a file handle with the standard file I/O functions.

Windows Sockets are based on the sockets first popularized by Berkeley Software Distribution (BSD). An application that uses Windows Sockets can communicate with other socket implementation on other types of systems. However, not all transport service providers support all available options.

Key Point: Windows Sockets is a protocol-independent interface capable of supporting current and emerging networking capabilities. For more information, see Windows Sockets 2.

 

 

Send comments about this topic to Microsoft

Build date: 1/27/2011

Community Content Add

Sockets for IPC

A negative for using sockets for IPC may be having to assign a port for the local host server. Is this a configuration hassle to find a unused port and make sure the firewall does not block the port for someone just wanting to create a service used by local clients. Named pipes and COM are probably the best for local IPC. Anyone at Microsoft or the developer community care to comment???

[SamB 2011-03-21]

The firewall does not appear to actually block local (loopback) traffic, at least not on XP. I have, however, seen the dialog appear when an application started listening on a port for this purpose, even though (if I remember correctly) the application appeared to be listening specifically on 127.0.0.1:1234 (except it probably wasn’t actually listening on port 1234).

Maximum Throughput for IPC?
Hello. Is there a maximum throughput when using IPC? We are using a 32-bit programming interface which could greatly benefit from 64-bit addressing space. Our thought is to create a separate 32-bit and 64-bit application, and use IPC to communicate between the two. The only potential pitfall is that we need to stream up to 480 MB of data per second. Are there any benchmarks on the maximum throughput of IPC? Here is our system: Windows 7 x64, 8 GB RAM, 2.3 GHz dual-core AMD Turion 64 X2 processor (upgrading to Intel i7 architecture soon), data is coming from x4 PCIe link.

프로그래밍 중 오류 처리 방법

다른 컴파일러는 많이 안 써봐서 모르겠는데…

비주얼스튜디오…

특히 2008 이후버전은 에러 메세지가 굉장히 친절하다

 

그 중에도 또 특히 닷넷은 더 친절하다.

기본문법만 익히고 에러메세지 보면서 처리 해 가면서 배워도 될 정도로….

컴파일 오류가 발생하면 에러메세지를 하나하나 처리하면 프로그램이 잘 돌아가게 된다.

아직 프로그래밍을 해 본지 얼마 안되서… 에러 메세지로 해결 못할 오류는 한번인가 만나봤었는데… 정확한 상황은 잘 기억이 안 난다. 그 전에 고쳤던 부분이 어딘지 알고 있어서 다행히 쉽게 고쳤던 것 같다.

 

에러메세지는 대부분 구글검색으로 해결한다.

90%가량은 그대로 따라하면서 처리가 가능하고 10%가량은 머리를 써서 처리해야 하는 복잡한 문제다.

 

error C2440: ‘static_cast’ : cannot convert from ‘void (__thiscall CWMCALOADERDlg::* )(WPARAM,LPARAM)’ to ‘LRESULT (__thiscall CWnd::* )(WPARAM,LPARAM)’

이런 에러 메세지는 그대로 붙여넣으면 검색결과가 전혀 나오지 않는다.

공통부분을 뽑아서 검색

error C2440: ‘static_cast’ : cannot convert from

error C2440: ‘static_cast’ : cannot convert from 여기에 void와 LRESULT를 추가해도 된다.

 

항상 네이버나 MSDN에서 찾는것보다 구글에서 검색하는게 백배 더 빠르다.

시간낭비를 줄이기 위해서~

error C2440: ‘static_cast’ : cannot convert from ‘~’ to ‘~’

error C2440: ‘static_cast’ : cannot convert from ‘void (__thiscall CWMCALOADERDlg::* )(WPARAM,LPARAM)’ to ‘LRESULT (__thiscall CWnd::* )(WPARAM,LPARAM)’

MSDN은 안보이는데… 관련 에러에 대한 다른 포스팅들

http://blog.stevienova.com/2007/02/28/error-c2440-static_cast-cannot-convert-from-uint-__thiscall-cstaticlink-cpoint-to-lresult-__thiscall-cwnd-cpoint/

 

가장 도움이 된 곳 http://devday.tistory.com/entry/error-C2440-staticcast-cannot-convert-from-void-thiscall-XXX-WPARAMLPARAM-to-LRESULT-thiscall-CWnd-WPARAMLPARAM

 

 

비슷한 오류가 많은 것 같은데…

처리방법은 이런식으로 응용하면 될 듯 하다.

이번 경우에는 에러메세지가 void랑 LRESULT랑 처리를 못 하겠다는 뭐 그런거니까…

void를 LRESULT형태로 바꿔준것..

missing type specifier – int assumed. Note: C++ does not support default-int

http://msdn.microsoft.com/ko-kr/library/ms173696(v=VS.100).aspx

MSDN에 한글로 번역돼있지만 뭔소린지 잘 모르겠다.

 

 

소스코드를 보면…int를 명시적으로 선언하라는 것 같다.

 

 

‘symbol’ : default-arguments are not allowed on this symbol

비주얼 스튜디오 에러 메세지
‘symbol’ : default-arguments are not allowed on this symbol

 

비주얼스튜디오 6에서는 통하던건데…

요즘은 이렇게 안 만들지만, 옛날 프로그래머들이 많이 해 놓은것들… 소스코드 받아서 실행시키면 아주 자주 발행하는 에러

VisualStudio6에서 프로그램을 안 배워봐서 파라미터는 받으면서 초기화하는게 왜 필요한지 진짜로 모르겠다. 이럴거면 파라미터로 받을 필요가 없잖아….

Writing Your First EventFlow Application

StreamBase DocumentationGetting Started

Writing Your First EventFlow Application

첫 이벤트플로우 어플리케이션

Purpose 목표

In this topic, you will develop your new MyFirstApp.sbapp EventFlow application.

여기서는 MyFirstApp.sbapp EventFlow application을 만들어보자.

Let’s briefly preview the steps in our application design process. First you will provide streams for events to enter and exit the application. You will define a schema that specifies what field names and data types your input stream expects. Then, you will add one or more operators to process the data. Finally, you will connect these components to determine how data flows through the application.

 

Preliminary Step

Before building your application:

  1. In the StreamBase Studio menu, click Window → Preferences. Expand the StreamBase Studio menu and open the Authoring page. Verify that the default setting, Automatically typecheck components, is enabled.To learn about typechecking, see About Typechecking in this topic.
  2. If your application is not already open in an EventFlow Editor, double-click MyFirstApp.sbapp in the Package Explorer to open it. You can have multiple editors open in this area of your perspective, each with its own tab labeled with the file name.Notice the Palette view under the Package Explorer. Whenever an EventFlow is open and its canvas is displayed, the palette is loaded with icons that represent the components you will use to design your EventFlow application. The icons are organized in drawers of different component types, as shown in the figure below.The Palette view is empty when no EventFlow canvas is displayed.

Building Your First EventFlow Application

Follow this procedure to develop the MyFirstApp.sbapp application.

  1. If your application is not already open in an EventFlow Editor, double-click its name (MyFirstApp.sbapp) in the Package Explorer to open it. You can have multiple editors open in this area of your perspective, each with its own tab labeled with the file name.
  2. Add the input stream and define its schema:
    1. In the Palette view, open the Streams category, then drag an Input Stream icon from the palette into your EventFlow canvas:

      Notice the yellow background of the InputStream1 icon: this color is a signal to you that the component does not typecheck yet — in this case, because there is no schema associated with it.

    2. Click the input stream icon in the canvas. When you click any component in an EventFlow Editor, StreamBase Studio opens its Properties view. In the following example, the Properties view is in the upper left:
    3. In the General tab, change the name of the input stream to TradesIn.
    4. Notice that the Edit Schema tab contains has a red  typecheck error icon. This icon should indicate to you that the tab needs attention, so open the Edit Schema tab. It contains an error message (notice the same red error icon) that attempts to help you fix the problem. In this case, it advises you to add fields to the schema.Click the  Add button twice to add a row for each field in the schema. Enter these values in the rows:
      Field Name Type Description
      symbol string Stock symbol
      quantity int Number of shares

      (The descriptions are optional.)

    5. Apply your changes: click a blank area on the canvas, or click the  Apply and Typecheck button near the top-right area of the Properties View. This forces Studio to typecheck your application now, instead of waiting for it to happen automatically. Note that typechecking does not save the application. You can write the application file to disk at any time with File → Save or Ctrl+S or by clicking the Save button in the main toolbar.When you apply your changes, notice that the background color of your TradesIn icon changes from yellow to white. That means the typecheck problem has been cleared, and that Studio is now aware of the schema for the TradesIn component.
  3. Add and configure a Filter operator:
    1. Open the Operators section of the Palette tab. Drag and drop a Filter operator from the palette onto the canvas. Its default name is Filter1. The canvas should now look similar to this:

      Notice that the Filter operator’s background color is yellow. This is because its typecheck status is unknown: it has not been connected yet to a component with a known and valid schema.

    2. If the Outline view is not open, click Window → Show View and choose Outline. This view provides a tree of all the components in your application. It can be helpful for navigating applications with many components. When your application was empty, its outline contained no instances, only a list of component types. Now, if you expand the Operators and Streams categories you should see your current components:
    3. Double-click the Filter1 instance in the Outline view: this selects the component in your canvas and opens its Properties view.
    4. In the General tab, change the name of the operator to TradeFilter.
    5. Open the Predicate Settings tab. Notice that a row in the Predicates table already exists for output port 1, with predicate expression true. Edit this expression in the Predicate column, and specify:quantity >= 10000predicate is an expression that resolves to either true or false for the values in a tuple. Here, the predicate is true for tuples containing trades of 10000 or more; all other tuples are false. The tuple is passed through the Filter operator only if it evaluates to true; all others are ignored.
    6. Now, let’s change the operation slightly: Instead of throwing away tuples with smaller trades, we want to make it possible to check them. To do this, we can make the Filter operators dequeue those tuples to a separate output stream.To make this change, select the option, Create output port for non-matching tuples.

    At this point, your Filter operator’s Properties view should look like this:

    At run time, the Filter operator will evaluate each tuple as it arrives from the input stream. If you had defined multiple predicates, they would be evaluated in order. The first predicate that returns truecauses the filter operation to occur immediately, and any later predicates are ignored.

    We have only one predicate, so each tuple is dequeued either on output port 1 if true, or on output port 2 (the port created for non-matching tuples) if false.

  4. Connect the input stream to the filter operator.The canvas shows each output port as a small black square on the right side of the component. If there are multiple output ports, the upper-most square represents Port 1; the next square down represents port 2, and so on. Your Filter operator now has an extra output port, which you configured in the preceding step.

    Find the output port on the TradesIn icon. Drag your cursor from that square to the input port (the square on the left side) of the filter operator. StreamBase Studio draws an arc connecting the two components. Arcs represent internal streams within EventFlow applications. When you connect the two components, the input stream and the filter operator backgrounds turn white, indicating that they typechecked successfully. For example:

  5. Add the output streams:
    1. Drag and drop an Output Stream icon from the palette into the canvas. Select the output stream on the canvas to open its Properties view.
    2. In the General tab, change the stream’s name to BigTrades.
    3. In the canvas, draw an arc from the upper output port of the Filter operator to the input port of the output stream. Your EventFlow application should look similar to this:
    4. Add a second output stream. Select the output stream, and in its Properties view, change its name to AllTheRest.
    5. Connect the lower output port of the Filter operator to the AllTheRest output stream.

      Tip

      If your canvas looks a little disorganized, try one or both of these adjustments:

      • To automatically arrange the components neatly on the canvas, click Diagram → Layout Application or press Ctrl+L.
      • To rearrange the arcs around components (for example, if an arc overlaps a component’s name), click Diagram → Reroute Connections.

      The final layout of your EventFlow application should look similar to the following:

  6. Use File → Save, Ctrl+S, or click the Save button to save your StreamBase Application.

About Typechecking

Typechecking is a kind of validation that StreamBase performs on each component of an application. A StreamBase application will not run if it has typecheck errors. One of the key advantages of designing inStreamBase Studio is that typechecking can be performed automatically as you work, so you can avoid accumulating problems.

Conceptually, typechecking occurs from the starting points of the application (usually the left side) — and proceeds to the downstream components (typically those connected on the right). When the typecheck process finds an error condition, the background color of the component turns to red, and downstream components cannot be typechecked yet. Typechecks can fail for a number of reasons, such as:

  • Incorrect operator parameters (for example, if the user edited the EventFlow file’s XML source code directly and entered an invalid parameter name or value).
  • Incorrect use of the expression language, such as an invalid character in a field name, again entered by a user who edited the sbapp XML directly.
  • An operator that does not have a schema declared yet.
  • An operator has a schema declared, but it is in conflict with the prior (upstream) connected operator.

Summary and Next Steps

In this topic you learned how to define a StreamBase schema, add components to your application, connect them together, and define functionality by editing the properties of one component. You also learned something about StreamBase typechecking. Your application doesn’t do much, but it’s finished and ready to run.

Do not close StreamBase Studio. To continue the tutorial, please click Next to proceed to one of the following topics:

  • If you would like to create a StreamSQL application, complete the next topic, Creating Your First StreamSQL Application.It will do exactly the same work as the MyFirstApp.sbapp application, and in subsequent topics, you will be able to run either version of the application with identical results.
  • If you are not interested in using StreamSQL, skip the next topic: click Next one more time to go on to Running Your First StreamBase Application .